<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Tc.Solver</span><span class="hs-special">(</span><span>
</span><span id="line-4"></span><span>       </span><span class="annot"><a href="GHC.Tc.Solver.html#simplifyInfer"><span class="hs-identifier">simplifyInfer</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.html#InferMode"><span class="hs-identifier">InferMode</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-5"></span><span>       </span><span class="annot"><a href="GHC.Tc.Solver.html#growThetaTyVars"><span class="hs-identifier">growThetaTyVars</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-6"></span><span>       </span><span class="annot"><a href="GHC.Tc.Solver.html#simplifyAmbiguityCheck"><span class="hs-identifier">simplifyAmbiguityCheck</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-7"></span><span>       </span><span class="annot"><a href="GHC.Tc.Solver.html#simplifyDefault"><span class="hs-identifier">simplifyDefault</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-8"></span><span>       </span><span class="annot"><a href="GHC.Tc.Solver.html#simplifyTop"><span class="hs-identifier">simplifyTop</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.html#simplifyTopImplic"><span class="hs-identifier">simplifyTopImplic</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-9"></span><span>       </span><span class="annot"><a href="GHC.Tc.Solver.html#simplifyInteractive"><span class="hs-identifier">simplifyInteractive</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-10"></span><span>       </span><span class="annot"><a href="GHC.Tc.Solver.html#solveEqualities"><span class="hs-identifier">solveEqualities</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.html#solveLocalEqualities"><span class="hs-identifier">solveLocalEqualities</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.html#solveLocalEqualitiesX"><span class="hs-identifier">solveLocalEqualitiesX</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-11"></span><span>       </span><span class="annot"><a href="GHC.Tc.Solver.html#simplifyWantedsTcM"><span class="hs-identifier">simplifyWantedsTcM</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-12"></span><span>       </span><span class="annot"><a href="GHC.Tc.Solver.html#tcCheckSatisfiability"><span class="hs-identifier">tcCheckSatisfiability</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-13"></span><span>       </span><span class="annot"><a href="GHC.Tc.Solver.html#tcNormalise"><span class="hs-identifier">tcNormalise</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-14"></span><span>
</span><span id="line-15"></span><span>       </span><span class="annot"><a href="GHC.Tc.Solver.html#captureTopConstraints"><span class="hs-identifier">captureTopConstraints</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-16"></span><span>
</span><span id="line-17"></span><span>       </span><span class="annot"><a href="GHC.Tc.Solver.html#simpl_top"><span class="hs-identifier">simpl_top</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#promoteTyVarSet"><span class="hs-identifier">promoteTyVarSet</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.html#emitFlatConstraints"><span class="hs-identifier">emitFlatConstraints</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span>       </span><span class="hs-comment">-- For Rules we need these</span><span>
</span><span id="line-22"></span><span>       </span><span class="annot"><a href="GHC.Tc.Solver.html#solveWanteds"><span class="hs-identifier">solveWanteds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.html#solveWantedsAndDrop"><span class="hs-identifier">solveWantedsAndDrop</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>       </span><span class="annot"><a href="GHC.Tc.Solver.html#approximateWC"><span class="hs-identifier">approximateWC</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#runTcSDeriveds"><span class="hs-identifier">runTcSDeriveds</span></a></span><span>
</span><span id="line-24"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html"><span class="hs-identifier">GHC.Data.Bag</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Class.html"><span class="hs-identifier">GHC.Core.Class</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier">Class</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#classKey"><span class="hs-identifier">classKey</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#classTyCon"><span class="hs-identifier">classTyCon</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Id.html#idType"><span class="hs-identifier">idType</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html"><span class="hs-identifier">GHC.Tc.Utils.Instantiate</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.List.SetOps.html"><span class="hs-identifier">GHC.Data.List.SetOps</span></a></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Utils.html"><span class="hs-identifier">GHC.Builtin.Utils</span></a></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html"><span class="hs-identifier">GHC.Builtin.Names</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Errors.html"><span class="hs-identifier">GHC.Tc.Errors</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html"><span class="hs-identifier">GHC.Tc.Types.Evidence</span></a></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Interact.html"><span class="hs-identifier">GHC.Tc.Solver.Interact</span></a></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html"><span class="hs-identifier">GHC.Tc.Solver.Canonical</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#makeSuperClasses"><span class="hs-identifier">makeSuperClasses</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Canonical.html#solveCallStack"><span class="hs-identifier">solveCallStack</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Flatten.html"><span class="hs-identifier">GHC.Tc.Solver.Flatten</span></a></span><span>     </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Flatten.html#flattenType"><span class="hs-identifier">flattenType</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html"><span class="hs-identifier">GHC.Tc.Utils.TcMType</span></a></span><span>   </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">TcM</span></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html"><span class="hs-identifier">GHC.Tc.Utils.Monad</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">TcM</span></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html"><span class="hs-identifier">GHC.Tc.Solver.Monad</span></a></span><span>  </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">TcS</span></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html"><span class="hs-identifier">GHC.Tc.Types.Constraint</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html"><span class="hs-identifier">GHC.Core.Predicate</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html"><span class="hs-identifier">GHC.Tc.Types.Origin</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html"><span class="hs-identifier">GHC.Tc.Utils.TcType</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html"><span class="hs-identifier">GHC.Builtin.Types</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html#liftedRepTy"><span class="hs-identifier">liftedRepTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html#manyDataConTy"><span class="hs-identifier">manyDataConTy</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html"><span class="hs-identifier">GHC.Core.Unify</span></a></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Unify.html#tcMatchTyKi"><span class="hs-identifier">tcMatchTyKi</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#IntWithInf"><span class="hs-identifier">IntWithInf</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#intGtLimit"><span class="hs-identifier">intGtLimit</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html"><span class="hs-identifier">GHC.Utils.Error</span></a></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#emptyMessages"><span class="hs-identifier">emptyMessages</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.LanguageExtensions.html#"><span class="hs-identifier">GHC.LanguageExtensions</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">LangExt</span></span><span>
</span><span id="line-61"></span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#"><span class="hs-identifier">Data.Foldable</span></a></span><span>      </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#toList"><span class="hs-identifier">toList</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>          </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#partition"><span class="hs-identifier">partition</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.NonEmpty.html#"><span class="hs-identifier">Data.List.NonEmpty</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#NonEmpty"><span class="hs-identifier">NonEmpty</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-66"></span><span>
</span><span id="line-67"></span><span class="hs-comment">{-
*********************************************************************************
*                                                                               *
*                           External interface                                  *
*                                                                               *
*********************************************************************************
-}</span><span>
</span><span id="line-74"></span><span>
</span><span id="line-75"></span><span id="local-6989586621681102634"><span class="annot"><a href="GHC.Tc.Solver.html#captureTopConstraints"><span class="hs-identifier hs-type">captureTopConstraints</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681102634"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621681102634"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-76"></span><span class="hs-comment">-- (captureTopConstraints m) runs m, and returns the type constraints it</span><span>
</span><span id="line-77"></span><span class="hs-comment">-- generates plus the constraints produced by static forms inside.</span><span>
</span><span id="line-78"></span><span class="hs-comment">-- If it fails with an exception, it reports any insolubles</span><span>
</span><span id="line-79"></span><span class="hs-comment">-- (out of scope variables) before doing so</span><span>
</span><span id="line-80"></span><span class="hs-comment">--</span><span>
</span><span id="line-81"></span><span class="hs-comment">-- captureTopConstraints is used exclusively by GHC.Tc.Module at the top</span><span>
</span><span id="line-82"></span><span class="hs-comment">-- level of a module.</span><span>
</span><span id="line-83"></span><span class="hs-comment">--</span><span>
</span><span id="line-84"></span><span class="hs-comment">-- Importantly, if captureTopConstraints propagates an exception, it</span><span>
</span><span id="line-85"></span><span class="hs-comment">-- reports any insoluble constraints first, lest they be lost</span><span>
</span><span id="line-86"></span><span class="hs-comment">-- altogether.  This is important, because solveLocalEqualities (maybe</span><span>
</span><span id="line-87"></span><span class="hs-comment">-- other things too) throws an exception without adding any error</span><span>
</span><span id="line-88"></span><span class="hs-comment">-- messages; it just puts the unsolved constraints back into the</span><span>
</span><span id="line-89"></span><span class="hs-comment">-- monad. See GHC.Tc.Utils.Monad Note [Constraints and errors]</span><span>
</span><span id="line-90"></span><span class="hs-comment">-- #16376 is an example of what goes wrong if you don't do this.</span><span>
</span><span id="line-91"></span><span class="hs-comment">--</span><span>
</span><span id="line-92"></span><span class="hs-comment">-- NB: the caller should bring any environments into scope before</span><span>
</span><span id="line-93"></span><span class="hs-comment">-- calling this, so that the reportUnsolved has access to the most</span><span>
</span><span id="line-94"></span><span class="hs-comment">-- complete GlobalRdrEnv</span><span>
</span><span id="line-95"></span><span id="captureTopConstraints"><span class="annot"><span class="annottext">captureTopConstraints :: forall a. TcM a -&gt; TcM (a, WantedConstraints)
</span><a href="GHC.Tc.Solver.html#captureTopConstraints"><span class="hs-identifier hs-var hs-var">captureTopConstraints</span></a></span></span><span> </span><span id="local-6989586621681101948"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681101948"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-96"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101947"><span class="annot"><span class="annottext">TcRef WantedConstraints
</span><a href="#local-6989586621681101947"><span class="hs-identifier hs-var">static_wc_var</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
-&gt; TcRnIf TcGblEnv TcLclEnv (TcRef WantedConstraints)
forall a gbl lcl. a -&gt; TcRnIf gbl lcl (TcRef a)
</span><a href="GHC.Tc.Utils.Monad.html#newTcRef"><span class="hs-identifier hs-var">TcM.newTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#emptyWC"><span class="hs-identifier hs-var">emptyWC</span></a></span><span> </span><span class="hs-special">;</span><span>
</span><span id="line-97"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101944"><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621681101944"><span class="hs-identifier hs-var">mb_res</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101943"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101943"><span class="hs-identifier hs-var">lie</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TcGblEnv -&gt; TcGblEnv)
-&gt; TcRnIf TcGblEnv TcLclEnv (Maybe a, WantedConstraints)
-&gt; TcRnIf TcGblEnv TcLclEnv (Maybe a, WantedConstraints)
forall gbl lcl a.
(gbl -&gt; gbl) -&gt; TcRnIf gbl lcl a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#updGblEnv"><span class="hs-identifier hs-var">TcM.updGblEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681101941"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681101941"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681101941"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcg_static_wc :: TcRef WantedConstraints
</span><a href="GHC.Tc.Types.html#tcg_static_wc"><span class="hs-identifier hs-var">tcg_static_wc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcRef WantedConstraints
</span><a href="#local-6989586621681101947"><span class="hs-identifier hs-var">static_wc_var</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcRnIf TcGblEnv TcLclEnv (Maybe a, WantedConstraints)
 -&gt; TcRnIf TcGblEnv TcLclEnv (Maybe a, WantedConstraints))
-&gt; TcRnIf TcGblEnv TcLclEnv (Maybe a, WantedConstraints)
-&gt; TcRnIf TcGblEnv TcLclEnv (Maybe a, WantedConstraints)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-98"></span><span>                          </span><span class="annot"><span class="annottext">TcM a -&gt; TcRnIf TcGblEnv TcLclEnv (Maybe a, WantedConstraints)
forall a. TcM a -&gt; TcM (Maybe a, WantedConstraints)
</span><a href="GHC.Tc.Utils.Monad.html#tryCaptureConstraints"><span class="hs-identifier hs-var">TcM.tryCaptureConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681101948"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-99"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101938"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101938"><span class="hs-identifier hs-var">stWC</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRef WantedConstraints
-&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
forall a gbl lcl. TcRef a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#readTcRef"><span class="hs-identifier hs-var">TcM.readTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">TcRef WantedConstraints
</span><a href="#local-6989586621681101947"><span class="hs-identifier hs-var">static_wc_var</span></a></span><span>
</span><span id="line-100"></span><span>
</span><span id="line-101"></span><span>       </span><span class="hs-comment">-- See GHC.Tc.Utils.Monad Note [Constraints and errors]</span><span>
</span><span id="line-102"></span><span>       </span><span class="hs-comment">-- If the thing_inside threw an exception, but generated some insoluble</span><span>
</span><span id="line-103"></span><span>       </span><span class="hs-comment">-- constraints, report the latter before propagating the exception</span><span>
</span><span id="line-104"></span><span>       </span><span class="hs-comment">-- Otherwise they will be lost altogether</span><span>
</span><span id="line-105"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621681101944"><span class="hs-identifier hs-var">mb_res</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-106"></span><span>           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681101936"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681101936"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(a, WantedConstraints) -&gt; TcM (a, WantedConstraints)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681101936"><span class="hs-identifier hs-var">res</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101943"><span class="hs-identifier hs-var">lie</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; WantedConstraints -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#andWC"><span class="hs-operator hs-var">`andWC`</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101938"><span class="hs-identifier hs-var">stWC</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-107"></span><span>           </span><span class="annot"><span class="annottext">Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">Bag EvBind
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcM (Bag EvBind)
</span><a href="GHC.Tc.Solver.html#simplifyTop"><span class="hs-identifier hs-var">simplifyTop</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101943"><span class="hs-identifier hs-var">lie</span></a></span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcM (a, WantedConstraints)
forall env a. IOEnv env a
</span><a href="GHC.Data.IOEnv.html#failM"><span class="hs-identifier hs-var">failM</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-108"></span><span>                </span><span class="hs-comment">-- This call to simplifyTop is the reason</span><span>
</span><span id="line-109"></span><span>                </span><span class="hs-comment">-- this function is here instead of GHC.Tc.Utils.Monad</span><span>
</span><span id="line-110"></span><span>                </span><span class="hs-comment">-- We call simplifyTop so that it does defaulting</span><span>
</span><span id="line-111"></span><span>                </span><span class="hs-comment">-- (esp of runtime-reps) before reporting errors</span><span>
</span><span id="line-112"></span><span>
</span><span id="line-113"></span><span class="annot"><a href="GHC.Tc.Solver.html#simplifyTopImplic"><span class="hs-identifier hs-type">simplifyTopImplic</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-114"></span><span id="simplifyTopImplic"><span class="annot"><span class="annottext">simplifyTopImplic :: Bag Implication -&gt; TcM ()
</span><a href="GHC.Tc.Solver.html#simplifyTopImplic"><span class="hs-identifier hs-var hs-var">simplifyTopImplic</span></a></span></span><span> </span><span id="local-6989586621681101933"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101933"><span class="hs-identifier hs-var">implics</span></a></span></span><span>
</span><span id="line-115"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101932"><span class="annot"><span class="annottext">Bag EvBind
</span><a href="#local-6989586621681101932"><span class="hs-identifier hs-var">empty_binds</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcM (Bag EvBind)
</span><a href="GHC.Tc.Solver.html#simplifyTop"><span class="hs-identifier hs-var">simplifyTop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag Implication -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#mkImplicWC"><span class="hs-identifier hs-var">mkImplicWC</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101933"><span class="hs-identifier hs-var">implics</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-116"></span><span>
</span><span id="line-117"></span><span>       </span><span class="hs-comment">-- Since all the inputs are implications the returned bindings will be empty</span><span>
</span><span id="line-118"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-identifier">MASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isEmptyBag</span><span> </span><span class="hs-identifier">empty_binds</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">empty_binds</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-119"></span><span>
</span><span id="line-120"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-121"></span><span>
</span><span id="line-122"></span><span class="annot"><a href="GHC.Tc.Solver.html#simplifyTop"><span class="hs-identifier hs-type">simplifyTop</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#EvBind"><span class="hs-identifier hs-type">EvBind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-123"></span><span class="hs-comment">-- Simplify top-level constraints</span><span>
</span><span id="line-124"></span><span class="hs-comment">-- Usually these will be implications,</span><span>
</span><span id="line-125"></span><span class="hs-comment">-- but when there is nothing to quantify we don't wrap</span><span>
</span><span id="line-126"></span><span class="hs-comment">-- in a degenerate implication, so we do that here instead</span><span>
</span><span id="line-127"></span><span id="simplifyTop"><span class="annot"><span class="annottext">simplifyTop :: WantedConstraints -&gt; TcM (Bag EvBind)
</span><a href="GHC.Tc.Solver.html#simplifyTop"><span class="hs-identifier hs-var hs-var">simplifyTop</span></a></span></span><span> </span><span id="local-6989586621681101924"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101924"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span>
</span><span id="line-128"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;simplifyTop {&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcM ()) -&gt; SDoc -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;wanted = &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101924"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-129"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621681101920"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101920"><span class="hs-identifier hs-var">final_wc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101919"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101919"><span class="hs-identifier hs-var">unsafe_ol</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101918"><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101918"><span class="hs-identifier hs-var">binds1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS (WantedConstraints, Cts)
-&gt; TcM ((WantedConstraints, Cts), EvBindMap)
forall a. TcS a -&gt; TcM (a, EvBindMap)
</span><a href="GHC.Tc.Solver.Monad.html#runTcS"><span class="hs-identifier hs-var">runTcS</span></a></span><span> </span><span class="annot"><span class="annottext">(TcS (WantedConstraints, Cts)
 -&gt; TcM ((WantedConstraints, Cts), EvBindMap))
-&gt; TcS (WantedConstraints, Cts)
-&gt; TcM ((WantedConstraints, Cts), EvBindMap)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-130"></span><span>            </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101916"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101916"><span class="hs-identifier hs-var">final_wc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#simpl_top"><span class="hs-identifier hs-var">simpl_top</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101924"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-131"></span><span>               </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101915"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101915"><span class="hs-identifier hs-var">unsafe_ol</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS Cts
</span><a href="GHC.Tc.Solver.Monad.html#getSafeOverlapFailures"><span class="hs-identifier hs-var">getSafeOverlapFailures</span></a></span><span>
</span><span id="line-132"></span><span>               </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(WantedConstraints, Cts) -&gt; TcS (WantedConstraints, Cts)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101916"><span class="hs-identifier hs-var">final_wc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101915"><span class="hs-identifier hs-var">unsafe_ol</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-133"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;End simplifyTop }&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-134"></span><span>
</span><span id="line-135"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101912"><span class="annot"><span class="annottext">Bag EvBind
</span><a href="#local-6989586621681101912"><span class="hs-identifier hs-var">binds2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcM (Bag EvBind)
</span><a href="GHC.Tc.Errors.html#reportUnsolved"><span class="hs-identifier hs-var">reportUnsolved</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101920"><span class="hs-identifier hs-var">final_wc</span></a></span><span>
</span><span id="line-136"></span><span>
</span><span id="line-137"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;reportUnsolved (unsafe overlapping) {&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-138"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcM () -&gt; TcM ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isEmptyCts"><span class="hs-identifier hs-var">isEmptyCts</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101919"><span class="hs-identifier hs-var">unsafe_ol</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcM () -&gt; TcM ()) -&gt; TcM () -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-139"></span><span>           </span><span class="hs-comment">-- grab current error messages and clear, warnAllUnsolved will</span><span>
</span><span id="line-140"></span><span>           </span><span class="hs-comment">-- update error messages which we'll grab and then restore saved</span><span>
</span><span id="line-141"></span><span>           </span><span class="hs-comment">-- messages.</span><span>
</span><span id="line-142"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101908"><span class="annot"><span class="annottext">TcRef Messages
</span><a href="#local-6989586621681101908"><span class="hs-identifier hs-var">errs_var</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn (TcRef Messages)
</span><a href="GHC.Tc.Utils.Monad.html#getErrsVar"><span class="hs-identifier hs-var">getErrsVar</span></a></span><span>
</span><span id="line-143"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101906"><span class="annot"><span class="annottext">Messages
</span><a href="#local-6989586621681101906"><span class="hs-identifier hs-var">saved_msg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRef Messages -&gt; TcRnIf TcGblEnv TcLclEnv Messages
forall a gbl lcl. TcRef a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#readTcRef"><span class="hs-identifier hs-var">TcM.readTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">TcRef Messages
</span><a href="#local-6989586621681101908"><span class="hs-identifier hs-var">errs_var</span></a></span><span>
</span><span id="line-144"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcRef Messages -&gt; Messages -&gt; TcM ()
forall a gbl lcl. TcRef a -&gt; a -&gt; TcRnIf gbl lcl ()
</span><a href="GHC.Tc.Utils.Monad.html#writeTcRef"><span class="hs-identifier hs-var">TcM.writeTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">TcRef Messages
</span><a href="#local-6989586621681101908"><span class="hs-identifier hs-var">errs_var</span></a></span><span> </span><span class="annot"><span class="annottext">Messages
</span><a href="GHC.Utils.Error.html#emptyMessages"><span class="hs-identifier hs-var">emptyMessages</span></a></span><span>
</span><span id="line-145"></span><span>
</span><span id="line-146"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcM ()
</span><a href="GHC.Tc.Errors.html#warnAllUnsolved"><span class="hs-identifier hs-var">warnAllUnsolved</span></a></span><span> </span><span class="annot"><span class="annottext">(WantedConstraints -&gt; TcM ()) -&gt; WantedConstraints -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#emptyWC"><span class="hs-identifier hs-var">emptyWC</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101919"><span class="hs-identifier hs-var">unsafe_ol</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-147"></span><span>
</span><span id="line-148"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101902"><span class="annot"><span class="annottext">WarningMessages
</span><a href="#local-6989586621681101902"><span class="hs-identifier hs-var">whyUnsafe</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Messages -&gt; WarningMessages
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">(Messages -&gt; WarningMessages)
-&gt; TcRnIf TcGblEnv TcLclEnv Messages
-&gt; IOEnv (Env TcGblEnv TcLclEnv) WarningMessages
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcRef Messages -&gt; TcRnIf TcGblEnv TcLclEnv Messages
forall a gbl lcl. TcRef a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#readTcRef"><span class="hs-identifier hs-var">TcM.readTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">TcRef Messages
</span><a href="#local-6989586621681101908"><span class="hs-identifier hs-var">errs_var</span></a></span><span>
</span><span id="line-149"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcRef Messages -&gt; Messages -&gt; TcM ()
forall a gbl lcl. TcRef a -&gt; a -&gt; TcRnIf gbl lcl ()
</span><a href="GHC.Tc.Utils.Monad.html#writeTcRef"><span class="hs-identifier hs-var">TcM.writeTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">TcRef Messages
</span><a href="#local-6989586621681101908"><span class="hs-identifier hs-var">errs_var</span></a></span><span> </span><span class="annot"><span class="annottext">Messages
</span><a href="#local-6989586621681101906"><span class="hs-identifier hs-var">saved_msg</span></a></span><span>
</span><span id="line-150"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WarningMessages -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#recordUnsafeInfer"><span class="hs-identifier hs-var">recordUnsafeInfer</span></a></span><span> </span><span class="annot"><span class="annottext">WarningMessages
</span><a href="#local-6989586621681101902"><span class="hs-identifier hs-var">whyUnsafe</span></a></span><span>
</span><span id="line-151"></span><span>           </span><span class="hs-special">}</span><span>
</span><span id="line-152"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;reportUnsolved (unsafe overlapping) }&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-153"></span><span>
</span><span id="line-154"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bag EvBind -&gt; TcM (Bag EvBind)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EvBindMap -&gt; Bag EvBind
</span><a href="GHC.Tc.Types.Evidence.html#evBindMapBinds"><span class="hs-identifier hs-var">evBindMapBinds</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101918"><span class="hs-identifier hs-var">binds1</span></a></span><span> </span><span class="annot"><span class="annottext">Bag EvBind -&gt; Bag EvBind -&gt; Bag EvBind
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">Bag EvBind
</span><a href="#local-6989586621681101912"><span class="hs-identifier hs-var">binds2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-155"></span><span>
</span><span id="line-156"></span><span>
</span><span id="line-157"></span><span class="hs-comment">-- | Type-check a thing that emits only equality constraints, solving any</span><span>
</span><span id="line-158"></span><span class="hs-comment">-- constraints we can and re-emitting constraints that we can't. The thing_inside</span><span>
</span><span id="line-159"></span><span class="hs-comment">-- should generally bump the TcLevel to make sure that this run of the solver</span><span>
</span><span id="line-160"></span><span class="hs-comment">-- doesn't affect anything lying around.</span><span>
</span><span id="line-161"></span><span id="local-6989586621681102594"><span class="annot"><a href="GHC.Tc.Solver.html#solveLocalEqualities"><span class="hs-identifier hs-type">solveLocalEqualities</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681102594"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681102594"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-162"></span><span class="hs-comment">-- Note [Failure in local type signatures]</span><span>
</span><span id="line-163"></span><span id="solveLocalEqualities"><span class="annot"><span class="annottext">solveLocalEqualities :: forall a. String -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Solver.html#solveLocalEqualities"><span class="hs-identifier hs-var hs-var">solveLocalEqualities</span></a></span></span><span> </span><span id="local-6989586621681101894"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681101894"><span class="hs-identifier hs-var">callsite</span></a></span></span><span> </span><span id="local-6989586621681101893"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681101893"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-164"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101892"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101892"><span class="hs-identifier hs-var">wanted</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101891"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681101891"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; TcM a -&gt; TcM (WantedConstraints, a)
forall a. String -&gt; TcM a -&gt; TcM (WantedConstraints, a)
</span><a href="GHC.Tc.Solver.html#solveLocalEqualitiesX"><span class="hs-identifier hs-var">solveLocalEqualitiesX</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681101894"><span class="hs-identifier hs-var">callsite</span></a></span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681101893"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-165"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcM ()
</span><a href="GHC.Tc.Solver.html#emitFlatConstraints"><span class="hs-identifier hs-var">emitFlatConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101892"><span class="hs-identifier hs-var">wanted</span></a></span><span>
</span><span id="line-166"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">a -&gt; TcM a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681101891"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-167"></span><span>
</span><span id="line-168"></span><span class="annot"><a href="GHC.Tc.Solver.html#emitFlatConstraints"><span class="hs-identifier hs-type">emitFlatConstraints</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-169"></span><span class="hs-comment">-- See Note [Failure in local type signatures]</span><span>
</span><span id="line-170"></span><span id="emitFlatConstraints"><span class="annot"><span class="annottext">emitFlatConstraints :: WantedConstraints -&gt; TcM ()
</span><a href="GHC.Tc.Solver.html#emitFlatConstraints"><span class="hs-identifier hs-var hs-var">emitFlatConstraints</span></a></span></span><span> </span><span id="local-6989586621681101890"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101890"><span class="hs-identifier hs-var">wanted</span></a></span></span><span>
</span><span id="line-171"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101889"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101889"><span class="hs-identifier hs-var">wanted</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
</span><a href="GHC.Tc.Utils.TcMType.html#zonkWC"><span class="hs-identifier hs-var">TcM.zonkWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101890"><span class="hs-identifier hs-var">wanted</span></a></span><span>
</span><span id="line-172"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Maybe (Cts, Bag Hole)
</span><a href="GHC.Tc.Solver.html#floatKindEqualities"><span class="hs-identifier hs-var">floatKindEqualities</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101889"><span class="hs-identifier hs-var">wanted</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-173"></span><span>           </span><span class="annot"><span class="annottext">Maybe (Cts, Bag Hole)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;emitFlatConstraints: failing&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101889"><span class="hs-identifier hs-var">wanted</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-174"></span><span>                         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#emitConstraints"><span class="hs-identifier hs-var">emitConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101889"><span class="hs-identifier hs-var">wanted</span></a></span><span> </span><span class="hs-comment">-- So they get reported!</span><span>
</span><span id="line-175"></span><span>                         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcM ()
forall env a. IOEnv env a
</span><a href="GHC.Data.IOEnv.html#failM"><span class="hs-identifier hs-var">failM</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-176"></span><span>           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101885"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101885"><span class="hs-identifier hs-var">simples</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101884"><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681101884"><span class="hs-identifier hs-var">holes</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-177"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; TcM Bool
</span><a href="GHC.Tc.Utils.TcMType.html#promoteTyVarSet"><span class="hs-identifier hs-var">promoteTyVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts -&gt; VarSet
</span><a href="GHC.Tc.Types.Constraint.html#tyCoVarsOfCts"><span class="hs-identifier hs-var">tyCoVarsOfCts</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101885"><span class="hs-identifier hs-var">simples</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-178"></span><span>                    </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;emitFlatConstraints:&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcM ()) -&gt; SDoc -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-179"></span><span>                      </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;simples:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Cts -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101885"><span class="hs-identifier hs-var">simples</span></a></span><span>
</span><span id="line-180"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;holes:  &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Hole -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681101884"><span class="hs-identifier hs-var">holes</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-181"></span><span>                    </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bag Hole -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#emitHoles"><span class="hs-identifier hs-var">emitHoles</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681101884"><span class="hs-identifier hs-var">holes</span></a></span><span> </span><span class="hs-comment">-- Holes don't need promotion</span><span>
</span><span id="line-182"></span><span>                    </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Cts -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#emitSimples"><span class="hs-identifier hs-var">emitSimples</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101885"><span class="hs-identifier hs-var">simples</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-183"></span><span>
</span><span id="line-184"></span><span class="annot"><a href="GHC.Tc.Solver.html#floatKindEqualities"><span class="hs-identifier hs-type">floatKindEqualities</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-185"></span><span class="hs-comment">-- Float out all the constraints from the WantedConstraints,</span><span>
</span><span id="line-186"></span><span class="hs-comment">-- Return Nothing if any constraints can't be floated (captured</span><span>
</span><span id="line-187"></span><span class="hs-comment">-- by skolems), or if there is an insoluble constraint, or</span><span>
</span><span id="line-188"></span><span class="hs-comment">-- IC_Telescope telescope error</span><span>
</span><span id="line-189"></span><span id="floatKindEqualities"><span class="annot"><span class="annottext">floatKindEqualities :: WantedConstraints -&gt; Maybe (Cts, Bag Hole)
</span><a href="GHC.Tc.Solver.html#floatKindEqualities"><span class="hs-identifier hs-var hs-var">floatKindEqualities</span></a></span></span><span> </span><span id="local-6989586621681101879"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101879"><span class="hs-identifier hs-var">wc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; WantedConstraints -&gt; Maybe (Cts, Bag Hole)
</span><a href="#local-6989586621681101878"><span class="hs-identifier hs-var">float_wc</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101879"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-190"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-191"></span><span>    </span><span class="annot"><a href="#local-6989586621681101878"><span class="hs-identifier hs-type">float_wc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyCoVarSet"><span class="hs-identifier hs-type">TcTyCoVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-192"></span><span>    </span><span id="local-6989586621681101878"><span class="annot"><span class="annottext">float_wc :: VarSet -&gt; WantedConstraints -&gt; Maybe (Cts, Bag Hole)
</span><a href="#local-6989586621681101878"><span class="hs-identifier hs-var hs-var">float_wc</span></a></span></span><span> </span><span id="local-6989586621681101875"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101875"><span class="hs-identifier hs-var">trapping_tvs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WC"><span class="hs-identifier hs-type">WC</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: WantedConstraints -&gt; Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101873"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101873"><span class="hs-identifier hs-var">simples</span></a></span></span><span>
</span><span id="line-193"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_impl :: WantedConstraints -&gt; Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101871"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101871"><span class="hs-identifier hs-var">implics</span></a></span></span><span>
</span><span id="line-194"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_holes :: WantedConstraints -&gt; Bag Hole
</span><a href="GHC.Tc.Types.Constraint.html#wc_holes"><span class="hs-identifier hs-var">wc_holes</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101869"><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681101869"><span class="hs-identifier hs-var">holes</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-195"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; Bool) -&gt; Cts -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Bool
</span><a href="#local-6989586621681101867"><span class="hs-identifier hs-var">is_floatable</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101873"><span class="hs-identifier hs-var">simples</span></a></span><span>
</span><span id="line-196"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101866"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101866"><span class="hs-identifier hs-var">inner_simples</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101865"><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681101865"><span class="hs-identifier hs-var">inner_holes</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-197"></span><span>                </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Implication -&gt; Maybe (Cts, Bag Hole))
-&gt; Bag Implication -&gt; Maybe (Cts, Bag Hole)
forall (m :: * -&gt; *) a b c.
Monad m =&gt;
(a -&gt; m (Bag b, Bag c)) -&gt; Bag a -&gt; m (Bag b, Bag c)
</span><a href="GHC.Data.Bag.html#flatMapBagPairM"><span class="hs-identifier hs-var">flatMapBagPairM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; Implication -&gt; Maybe (Cts, Bag Hole)
</span><a href="#local-6989586621681101863"><span class="hs-identifier hs-var">float_implic</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101875"><span class="hs-identifier hs-var">trapping_tvs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101871"><span class="hs-identifier hs-var">implics</span></a></span><span>
</span><span id="line-198"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Cts, Bag Hole) -&gt; Maybe (Cts, Bag Hole)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101873"><span class="hs-identifier hs-var">simples</span></a></span><span> </span><span class="annot"><span class="annottext">Cts -&gt; Cts -&gt; Cts
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101866"><span class="hs-identifier hs-var">inner_simples</span></a></span><span>
</span><span id="line-199"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681101869"><span class="hs-identifier hs-var">holes</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Hole -&gt; Bag Hole -&gt; Bag Hole
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681101865"><span class="hs-identifier hs-var">inner_holes</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-200"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-201"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (Cts, Bag Hole)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-202"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-203"></span><span>        </span><span id="local-6989586621681101867"><span class="annot"><span class="annottext">is_floatable :: Ct -&gt; Bool
</span><a href="#local-6989586621681101867"><span class="hs-identifier hs-var hs-var">is_floatable</span></a></span></span><span> </span><span id="local-6989586621681101862"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101862"><span class="hs-identifier hs-var">ct</span></a></span></span><span>
</span><span id="line-204"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#insolubleEqCt"><span class="hs-identifier hs-var">insolubleEqCt</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101862"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-205"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; VarSet
</span><a href="GHC.Tc.Types.Constraint.html#tyCoVarsOfCt"><span class="hs-identifier hs-var">tyCoVarsOfCt</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101862"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#disjointVarSet"><span class="hs-operator hs-var">`disjointVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101875"><span class="hs-identifier hs-var">trapping_tvs</span></a></span><span>
</span><span id="line-206"></span><span>
</span><span id="line-207"></span><span>    </span><span class="annot"><a href="#local-6989586621681101863"><span class="hs-identifier hs-type">float_implic</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyCoVarSet"><span class="hs-identifier hs-type">TcTyCoVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-208"></span><span>    </span><span id="local-6989586621681101863"><span class="annot"><span class="annottext">float_implic :: VarSet -&gt; Implication -&gt; Maybe (Cts, Bag Hole)
</span><a href="#local-6989586621681101863"><span class="hs-identifier hs-var hs-var">float_implic</span></a></span></span><span> </span><span id="local-6989586621681101858"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101858"><span class="hs-identifier hs-var">trapping_tvs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implic"><span class="hs-identifier hs-type">Implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: Implication -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101855"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101855"><span class="hs-identifier hs-var">wanted</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_no_eqs :: Implication -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#ic_no_eqs"><span class="hs-identifier hs-var">ic_no_eqs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101853"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101853"><span class="hs-identifier hs-var">no_eqs</span></a></span></span><span>
</span><span id="line-209"></span><span>                                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_skols :: Implication -&gt; [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_skols"><span class="hs-identifier hs-var">ic_skols</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101851"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101851"><span class="hs-identifier hs-var">skols</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_status :: Implication -&gt; ImplicStatus
</span><a href="GHC.Tc.Types.Constraint.html#ic_status"><span class="hs-identifier hs-var">ic_status</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101849"><span class="annot"><span class="annottext">ImplicStatus
</span><a href="#local-6989586621681101849"><span class="hs-identifier hs-var">status</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-210"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">ImplicStatus -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isInsolubleStatus"><span class="hs-identifier hs-var">isInsolubleStatus</span></a></span><span> </span><span class="annot"><span class="annottext">ImplicStatus
</span><a href="#local-6989586621681101849"><span class="hs-identifier hs-var">status</span></a></span><span>
</span><span id="line-211"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (Cts, Bag Hole)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-comment">-- A short cut /plus/ we must keep track of IC_BadTelescope</span><span>
</span><span id="line-212"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-213"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101847"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101847"><span class="hs-identifier hs-var">simples</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101846"><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681101846"><span class="hs-identifier hs-var">holes</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; WantedConstraints -&gt; Maybe (Cts, Bag Hole)
</span><a href="#local-6989586621681101878"><span class="hs-identifier hs-var">float_wc</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101845"><span class="hs-identifier hs-var">new_trapping_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101855"><span class="hs-identifier hs-var">wanted</span></a></span><span>
</span><span id="line-214"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Maybe () -&gt; Maybe ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts -&gt; Bool
forall a. Bag a -&gt; Bool
</span><a href="GHC.Data.Bag.html#isEmptyBag"><span class="hs-identifier hs-var">isEmptyBag</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101847"><span class="hs-identifier hs-var">simples</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101853"><span class="hs-identifier hs-var">no_eqs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Maybe () -&gt; Maybe ()) -&gt; Maybe () -&gt; Maybe ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-215"></span><span>             </span><span class="annot"><span class="annottext">Maybe ()
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-216"></span><span>                 </span><span class="hs-comment">-- If there are some constraints to float out, but we can't</span><span>
</span><span id="line-217"></span><span>                 </span><span class="hs-comment">-- because we don't float out past local equalities</span><span>
</span><span id="line-218"></span><span>                 </span><span class="hs-comment">-- (c.f GHC.Tc.Solver.approximateWC), then fail</span><span>
</span><span id="line-219"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Cts, Bag Hole) -&gt; Maybe (Cts, Bag Hole)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101847"><span class="hs-identifier hs-var">simples</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681101846"><span class="hs-identifier hs-var">holes</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-220"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-221"></span><span>        </span><span id="local-6989586621681101845"><span class="annot"><span class="annottext">new_trapping_tvs :: VarSet
</span><a href="#local-6989586621681101845"><span class="hs-identifier hs-var hs-var">new_trapping_tvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101858"><span class="hs-identifier hs-var">trapping_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; [TcTyVar] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSetList"><span class="hs-operator hs-var">`extendVarSetList`</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101851"><span class="hs-identifier hs-var">skols</span></a></span><span>
</span><span id="line-222"></span><span>
</span><span id="line-223"></span><span>
</span><span id="line-224"></span><span class="hs-comment">{- Note [Failure in local type signatures]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When kind checking a type signature, we like to fail fast if we can't
solve all the kind equality constraints: see Note [Fail fast on kind
errors].  But what about /local/ type signatures, mentioning in-scope
type variables for which there might be given equalities.  Here's
an example (T15076b):

  class (a ~ b) =&gt; C a b
  data SameKind :: k -&gt; k -&gt; Type where { SK :: SameKind a b }

  bar :: forall (a :: Type) (b :: Type).
         C a b =&gt; Proxy a -&gt; Proxy b -&gt; ()
  bar _ _ = const () (undefined :: forall (x :: a) (y :: b). SameKind x y)

Consider the type singature on 'undefined'. It's ill-kinded unless
a~b.  But the superclass of (C a b) means that indeed (a~b). So all
should be well. BUT it's hard to see that when kind-checking the signature
for undefined.  We want to emit a residual (a~b) constraint, to solve
later.

Another possiblity is that we might have something like
   F alpha ~ [Int]
where alpha is bound further out, which might become soluble
&quot;later&quot; when we learn more about alpha.  So we want to emit
those residual constraints.

BUT it's no good simply wrapping all unsolved constraints from
a type signature in an implication constraint to solve later. The
problem is that we are going to /use/ that signature, including
instantiate it.  Say we have
     f :: forall a.  (forall b. blah) -&gt; blah2
     f x = &lt;body&gt;
To typecheck the definition of f, we have to instantiate those
foralls.  Moreover, any unsolved kind equalities will be coercion
holes in the type.  If we naively wrap them in an implication like
     forall a. (co1:k1~k2,  forall b.  co2:k3~k4)
hoping to solve it later, we might end up filling in the holes
co1 and co2 with coercions involving 'a' and 'b' -- but by now
we've instantiated the type.  Chaos!

Moreover, the unsolved constraints might be skolem-escpae things, and
if we proceed with f bound to a nonsensical type, we get a cascade of
follow-up errors. For example polykinds/T12593, T15577, and many others.

So here's the plan:

* solveLocalEqualitiesX: try to solve the constraints (solveLocalEqualitiesX)

* buildTvImplication: build an implication for the residual, unsolved
  constraint

* emitFlatConstraints: try to float out every unsolved equalities
  inside that implication, in the hope that it constrains only global
  type variables, not the locally-quantified ones.

  * If we fail, or find an insoluble constraint, emit the implication,
    so that the errors will be reported, and fail.

  * If we succeed in floating all the equalities, promote them and
    re-emit them as flat constraint, not wrapped at all (since they
    don't mention any of the quantified variables.

* Note that this float-and-promote step means that anonymous
  wildcards get floated to top level, as we want; see
  Note [Checking partial type signatures] in GHC.Tc.Gen.HsType.

All this is done:

* in solveLocalEqualities, where there is no kind-generalisation
  to complicate matters.

* in GHC.Tc.Gen.HsType.tcHsSigType, where quantification intervenes.

See also #18062, #11506
-}</span><span>
</span><span id="line-300"></span><span>
</span><span id="line-301"></span><span id="local-6989586621681102592"><span class="annot"><a href="GHC.Tc.Solver.html#solveLocalEqualitiesX"><span class="hs-identifier hs-type">solveLocalEqualitiesX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681102592"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621681102592"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-302"></span><span id="solveLocalEqualitiesX"><span class="annot"><span class="annottext">solveLocalEqualitiesX :: forall a. String -&gt; TcM a -&gt; TcM (WantedConstraints, a)
</span><a href="GHC.Tc.Solver.html#solveLocalEqualitiesX"><span class="hs-identifier hs-var hs-var">solveLocalEqualitiesX</span></a></span></span><span> </span><span id="local-6989586621681101834"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681101834"><span class="hs-identifier hs-var">callsite</span></a></span></span><span> </span><span id="local-6989586621681101833"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681101833"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-303"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;solveLocalEqualitiesX {&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Called from&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681101834"><span class="hs-identifier hs-var">callsite</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-304"></span><span>
</span><span id="line-305"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101832"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681101832"><span class="hs-identifier hs-var">result</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101831"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101831"><span class="hs-identifier hs-var">wanted</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM a -&gt; TcM (a, WantedConstraints)
forall a. TcM a -&gt; TcM (a, WantedConstraints)
</span><a href="GHC.Tc.Utils.Monad.html#captureConstraints"><span class="hs-identifier hs-var">captureConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681101833"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-306"></span><span>
</span><span id="line-307"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;solveLocalEqualities: running solver&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101831"><span class="hs-identifier hs-var">wanted</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-308"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101829"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101829"><span class="hs-identifier hs-var">residual_wanted</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS WantedConstraints -&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
forall a. TcS a -&gt; TcM a
</span><a href="GHC.Tc.Solver.Monad.html#runTcSEqualities"><span class="hs-identifier hs-var">runTcSEqualities</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#solveWanteds"><span class="hs-identifier hs-var">solveWanteds</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101831"><span class="hs-identifier hs-var">wanted</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-309"></span><span>
</span><span id="line-310"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;solveLocalEqualitiesX end }&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcM ()) -&gt; SDoc -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-311"></span><span>         </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;residual_wanted =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101829"><span class="hs-identifier hs-var">residual_wanted</span></a></span><span>
</span><span id="line-312"></span><span>
</span><span id="line-313"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(WantedConstraints, a) -&gt; TcM (WantedConstraints, a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101829"><span class="hs-identifier hs-var">residual_wanted</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681101832"><span class="hs-identifier hs-var">result</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-314"></span><span>
</span><span id="line-315"></span><span class="hs-comment">-- | Type-check a thing that emits only equality constraints, then</span><span>
</span><span id="line-316"></span><span class="hs-comment">-- solve those constraints. Fails outright if there is trouble.</span><span>
</span><span id="line-317"></span><span class="hs-comment">-- Use this if you're not going to get another crack at solving</span><span>
</span><span id="line-318"></span><span class="hs-comment">-- (because, e.g., you're checking a datatype declaration)</span><span>
</span><span id="line-319"></span><span id="local-6989586621681102581"><span class="annot"><a href="GHC.Tc.Solver.html#solveEqualities"><span class="hs-identifier hs-type">solveEqualities</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681102581"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681102581"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-320"></span><span id="solveEqualities"><span class="annot"><span class="annottext">solveEqualities :: forall a. TcM a -&gt; TcM a
</span><a href="GHC.Tc.Solver.html#solveEqualities"><span class="hs-identifier hs-var hs-var">solveEqualities</span></a></span></span><span> </span><span id="local-6989586621681101817"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681101817"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-321"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcM a -&gt; TcM a
forall a. TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#checkNoErrs"><span class="hs-identifier hs-var">checkNoErrs</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM a -&gt; TcM a) -&gt; TcM a -&gt; TcM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>  </span><span class="hs-comment">-- See Note [Fail fast on kind errors]</span><span>
</span><span id="line-322"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101815"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101815"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcLevel
</span><a href="GHC.Tc.Utils.Monad.html#getTcLevel"><span class="hs-identifier hs-var">TcM.getTcLevel</span></a></span><span>
</span><span id="line-323"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;solveEqualities {&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;level =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101815"><span class="hs-identifier hs-var">lvl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-324"></span><span>
</span><span id="line-325"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101813"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681101813"><span class="hs-identifier hs-var">result</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101812"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101812"><span class="hs-identifier hs-var">wanted</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM a -&gt; TcM (a, WantedConstraints)
forall a. TcM a -&gt; TcM (a, WantedConstraints)
</span><a href="GHC.Tc.Utils.Monad.html#captureConstraints"><span class="hs-identifier hs-var">captureConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681101817"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-326"></span><span>
</span><span id="line-327"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;solveEqualities: running solver&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcM ()) -&gt; SDoc -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;wanted = &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101812"><span class="hs-identifier hs-var">wanted</span></a></span><span>
</span><span id="line-328"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101811"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101811"><span class="hs-identifier hs-var">final_wc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS WantedConstraints -&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
forall a. TcS a -&gt; TcM a
</span><a href="GHC.Tc.Solver.Monad.html#runTcSEqualities"><span class="hs-identifier hs-var">runTcSEqualities</span></a></span><span> </span><span class="annot"><span class="annottext">(TcS WantedConstraints
 -&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints)
-&gt; TcS WantedConstraints
-&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#simpl_top"><span class="hs-identifier hs-var">simpl_top</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101812"><span class="hs-identifier hs-var">wanted</span></a></span><span>
</span><span id="line-329"></span><span>          </span><span class="hs-comment">-- NB: Use simpl_top here so that we potentially default RuntimeRep</span><span>
</span><span id="line-330"></span><span>          </span><span class="hs-comment">-- vars to LiftedRep. This is needed to avoid #14991.</span><span>
</span><span id="line-331"></span><span>
</span><span id="line-332"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;End solveEqualities }&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-333"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcM ()
</span><a href="GHC.Tc.Errors.html#reportAllUnsolved"><span class="hs-identifier hs-var">reportAllUnsolved</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101811"><span class="hs-identifier hs-var">final_wc</span></a></span><span>
</span><span id="line-334"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">a -&gt; TcM a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681101813"><span class="hs-identifier hs-var">result</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-335"></span><span>
</span><span id="line-336"></span><span class="hs-comment">-- | Simplify top-level constraints, but without reporting any unsolved</span><span>
</span><span id="line-337"></span><span class="hs-comment">-- constraints nor unsafe overlapping.</span><span>
</span><span id="line-338"></span><span class="annot"><a href="GHC.Tc.Solver.html#simpl_top"><span class="hs-identifier hs-type">simpl_top</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-339"></span><span>    </span><span class="hs-comment">-- See Note [Top-level Defaulting Plan]</span><span>
</span><span id="line-340"></span><span id="simpl_top"><span class="annot"><span class="annottext">simpl_top :: WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#simpl_top"><span class="hs-identifier hs-var hs-var">simpl_top</span></a></span></span><span> </span><span id="local-6989586621681101809"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101809"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span>
</span><span id="line-341"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101808"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101808"><span class="hs-identifier hs-var">wc_first_go</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS WantedConstraints -&gt; TcS WantedConstraints
forall a. TcS a -&gt; TcS a
</span><a href="GHC.Tc.Solver.Monad.html#nestTcS"><span class="hs-identifier hs-var">nestTcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#solveWantedsAndDrop"><span class="hs-identifier hs-var">solveWantedsAndDrop</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101809"><span class="hs-identifier hs-var">wanteds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-342"></span><span>                            </span><span class="hs-comment">-- This is where the main work happens</span><span>
</span><span id="line-343"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101806"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681101806"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-344"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; WantedConstraints -&gt; TcS WantedConstraints
</span><a href="#local-6989586621681101804"><span class="hs-identifier hs-var">try_tyvar_defaulting</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681101806"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101808"><span class="hs-identifier hs-var">wc_first_go</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-345"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-346"></span><span>    </span><span class="annot"><a href="#local-6989586621681101804"><span class="hs-identifier hs-type">try_tyvar_defaulting</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-347"></span><span>    </span><span id="local-6989586621681101804"><span class="annot"><span class="annottext">try_tyvar_defaulting :: DynFlags -&gt; WantedConstraints -&gt; TcS WantedConstraints
</span><a href="#local-6989586621681101804"><span class="hs-identifier hs-var hs-var">try_tyvar_defaulting</span></a></span></span><span> </span><span id="local-6989586621681101803"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681101803"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681101802"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101802"><span class="hs-identifier hs-var">wc</span></a></span></span><span>
</span><span id="line-348"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isEmptyWC"><span class="hs-identifier hs-var">isEmptyWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101802"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-349"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101802"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-350"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#insolubleWC"><span class="hs-identifier hs-var">insolubleWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101802"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-351"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_PrintExplicitRuntimeReps"><span class="hs-identifier hs-var">Opt_PrintExplicitRuntimeReps</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681101803"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-comment">-- See Note [Defaulting insolubles]</span><span>
</span><span id="line-352"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="#local-6989586621681101797"><span class="hs-identifier hs-var">try_class_defaulting</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101802"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-353"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-354"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101796"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101796"><span class="hs-identifier hs-var">free_tvs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; TcS [TcTyVar]
</span><a href="GHC.Tc.Solver.Monad.html#zonkTyCoVarsAndFVList"><span class="hs-identifier hs-var">TcS.zonkTyCoVarsAndFVList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#tyCoVarsOfWCList"><span class="hs-identifier hs-var">tyCoVarsOfWCList</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101802"><span class="hs-identifier hs-var">wc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-355"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101791"><span class="annot"><span class="annottext">meta_tvs :: [TcTyVar]
</span><a href="#local-6989586621681101791"><span class="hs-identifier hs-var hs-var">meta_tvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcTyVar -&gt; Bool) -&gt; [TcTyVar] -&gt; [TcTyVar]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">(TcTyVar -&gt; Bool) -&gt; (TcTyVar -&gt; Bool) -&gt; TcTyVar -&gt; Bool
forall (f :: * -&gt; *). Applicative f =&gt; f Bool -&gt; f Bool -&gt; f Bool
</span><a href="GHC.Utils.Misc.html#%3C%26%26%3E"><span class="hs-operator hs-var">&lt;&amp;&amp;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isMetaTyVar"><span class="hs-identifier hs-var">isMetaTyVar</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101796"><span class="hs-identifier hs-var">free_tvs</span></a></span><span>
</span><span id="line-356"></span><span>                   </span><span class="hs-comment">-- zonkTyCoVarsAndFV: the wc_first_go is not yet zonked</span><span>
</span><span id="line-357"></span><span>                   </span><span class="hs-comment">-- filter isMetaTyVar: we might have runtime-skolems in GHCi,</span><span>
</span><span id="line-358"></span><span>                   </span><span class="hs-comment">-- and we definitely don't want to try to assign to those!</span><span>
</span><span id="line-359"></span><span>                   </span><span class="hs-comment">-- The isTyVar is needed to weed out coercion variables</span><span>
</span><span id="line-360"></span><span>
</span><span id="line-361"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101787"><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621681101787"><span class="hs-identifier hs-var">defaulted</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TcTyVar -&gt; TcS Bool) -&gt; [TcTyVar] -&gt; TcS [Bool]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcS Bool
</span><a href="GHC.Tc.Solver.html#defaultTyVarTcS"><span class="hs-identifier hs-var">defaultTyVarTcS</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101791"><span class="hs-identifier hs-var">meta_tvs</span></a></span><span>   </span><span class="hs-comment">-- Has unification side effects</span><span>
</span><span id="line-362"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">[Bool] -&gt; Bool
forall (t :: * -&gt; *). Foldable t =&gt; t Bool -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#or"><span class="hs-identifier hs-var">or</span></a></span><span> </span><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621681101787"><span class="hs-identifier hs-var">defaulted</span></a></span><span>
</span><span id="line-363"></span><span>             </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101783"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101783"><span class="hs-identifier hs-var">wc_residual</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS WantedConstraints -&gt; TcS WantedConstraints
forall a. TcS a -&gt; TcS a
</span><a href="GHC.Tc.Solver.Monad.html#nestTcS"><span class="hs-identifier hs-var">nestTcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#solveWanteds"><span class="hs-identifier hs-var">solveWanteds</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101802"><span class="hs-identifier hs-var">wc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-364"></span><span>                            </span><span class="hs-comment">-- See Note [Must simplify after defaulting]</span><span>
</span><span id="line-365"></span><span>                     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="#local-6989586621681101797"><span class="hs-identifier hs-var">try_class_defaulting</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101783"><span class="hs-identifier hs-var">wc_residual</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-366"></span><span>             </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="#local-6989586621681101797"><span class="hs-identifier hs-var">try_class_defaulting</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101802"><span class="hs-identifier hs-var">wc</span></a></span><span> </span><span class="hs-special">}</span><span>     </span><span class="hs-comment">-- No defaulting took place</span><span>
</span><span id="line-367"></span><span>
</span><span id="line-368"></span><span>    </span><span class="annot"><a href="#local-6989586621681101797"><span class="hs-identifier hs-type">try_class_defaulting</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-369"></span><span>    </span><span id="local-6989586621681101797"><span class="annot"><span class="annottext">try_class_defaulting :: WantedConstraints -&gt; TcS WantedConstraints
</span><a href="#local-6989586621681101797"><span class="hs-identifier hs-var hs-var">try_class_defaulting</span></a></span></span><span> </span><span id="local-6989586621681101782"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101782"><span class="hs-identifier hs-var">wc</span></a></span></span><span>
</span><span id="line-370"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isEmptyWC"><span class="hs-identifier hs-var">isEmptyWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101782"><span class="hs-identifier hs-var">wc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#insolubleWC"><span class="hs-identifier hs-var">insolubleWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101782"><span class="hs-identifier hs-var">wc</span></a></span><span> </span><span class="hs-comment">-- See Note [Defaulting insolubles]</span><span>
</span><span id="line-371"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101782"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-372"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-comment">-- See Note [When to do type-class defaulting]</span><span>
</span><span id="line-373"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101780"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101780"><span class="hs-identifier hs-var">something_happened</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS Bool
</span><a href="GHC.Tc.Solver.html#applyDefaultingRules"><span class="hs-identifier hs-var">applyDefaultingRules</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101782"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-374"></span><span>                                   </span><span class="hs-comment">-- See Note [Top-level Defaulting Plan]</span><span>
</span><span id="line-375"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101780"><span class="hs-identifier hs-var">something_happened</span></a></span><span>
</span><span id="line-376"></span><span>             </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101778"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101778"><span class="hs-identifier hs-var">wc_residual</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS WantedConstraints -&gt; TcS WantedConstraints
forall a. TcS a -&gt; TcS a
</span><a href="GHC.Tc.Solver.Monad.html#nestTcS"><span class="hs-identifier hs-var">nestTcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#solveWantedsAndDrop"><span class="hs-identifier hs-var">solveWantedsAndDrop</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101782"><span class="hs-identifier hs-var">wc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-377"></span><span>                     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="#local-6989586621681101797"><span class="hs-identifier hs-var">try_class_defaulting</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101778"><span class="hs-identifier hs-var">wc_residual</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-378"></span><span>                  </span><span class="hs-comment">-- See Note [Overview of implicit CallStacks] in GHC.Tc.Types.Evidence</span><span>
</span><span id="line-379"></span><span>             </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="#local-6989586621681101777"><span class="hs-identifier hs-var">try_callstack_defaulting</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101782"><span class="hs-identifier hs-var">wc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-380"></span><span>
</span><span id="line-381"></span><span>    </span><span class="annot"><a href="#local-6989586621681101777"><span class="hs-identifier hs-type">try_callstack_defaulting</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-382"></span><span>    </span><span id="local-6989586621681101777"><span class="annot"><span class="annottext">try_callstack_defaulting :: WantedConstraints -&gt; TcS WantedConstraints
</span><a href="#local-6989586621681101777"><span class="hs-identifier hs-var hs-var">try_callstack_defaulting</span></a></span></span><span> </span><span id="local-6989586621681101776"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101776"><span class="hs-identifier hs-var">wc</span></a></span></span><span>
</span><span id="line-383"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isEmptyWC"><span class="hs-identifier hs-var">isEmptyWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101776"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-384"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101776"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-385"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-386"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#defaultCallStacks"><span class="hs-identifier hs-var">defaultCallStacks</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101776"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-387"></span><span>
</span><span id="line-388"></span><span class="hs-comment">-- | Default any remaining @CallStack@ constraints to empty @CallStack@s.</span><span>
</span><span id="line-389"></span><span class="annot"><a href="GHC.Tc.Solver.html#defaultCallStacks"><span class="hs-identifier hs-type">defaultCallStacks</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-390"></span><span class="hs-comment">-- See Note [Overview of implicit CallStacks] in GHC.Tc.Types.Evidence</span><span>
</span><span id="line-391"></span><span id="defaultCallStacks"><span class="annot"><span class="annottext">defaultCallStacks :: WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#defaultCallStacks"><span class="hs-identifier hs-var hs-var">defaultCallStacks</span></a></span></span><span> </span><span id="local-6989586621681101774"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101774"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span>
</span><span id="line-392"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681101773"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101773"><span class="hs-identifier hs-var">simples</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Cts -&gt; TcS Cts
</span><a href="#local-6989586621681101772"><span class="hs-identifier hs-var">handle_simples</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var hs-var">wc_simple</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101774"><span class="hs-identifier hs-var">wanteds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-393"></span><span>       </span><span id="local-6989586621681101771"><span class="annot"><span class="annottext">Bag (Maybe Implication)
</span><a href="#local-6989586621681101771"><span class="hs-identifier hs-var">mb_implics</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Implication -&gt; TcS (Maybe Implication))
-&gt; Bag Implication -&gt; TcS (Bag (Maybe Implication))
forall (m :: * -&gt; *) a b.
Monad m =&gt;
(a -&gt; m b) -&gt; Bag a -&gt; m (Bag b)
</span><a href="GHC.Data.Bag.html#mapBagM"><span class="hs-identifier hs-var">mapBagM</span></a></span><span> </span><span class="annot"><span class="annottext">Implication -&gt; TcS (Maybe Implication)
</span><a href="#local-6989586621681101769"><span class="hs-identifier hs-var">handle_implic</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var hs-var">wc_impl</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101774"><span class="hs-identifier hs-var">wanteds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-394"></span><span>       </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101774"><span class="hs-identifier hs-var">wanteds</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101773"><span class="hs-identifier hs-var">simples</span></a></span><span>
</span><span id="line-395"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_impl :: Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag (Maybe Implication) -&gt; Bag Implication
forall a. Bag (Maybe a) -&gt; Bag a
</span><a href="GHC.Data.Bag.html#catBagMaybes"><span class="hs-identifier hs-var">catBagMaybes</span></a></span><span> </span><span class="annot"><span class="annottext">Bag (Maybe Implication)
</span><a href="#local-6989586621681101771"><span class="hs-identifier hs-var">mb_implics</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-396"></span><span>
</span><span id="line-397"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-398"></span><span>
</span><span id="line-399"></span><span>  </span><span id="local-6989586621681101772"><span class="annot"><span class="annottext">handle_simples :: Cts -&gt; TcS Cts
</span><a href="#local-6989586621681101772"><span class="hs-identifier hs-var hs-var">handle_simples</span></a></span></span><span> </span><span id="local-6989586621681101764"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101764"><span class="hs-identifier hs-var">simples</span></a></span></span><span>
</span><span id="line-400"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag (Maybe Ct) -&gt; Cts
forall a. Bag (Maybe a) -&gt; Bag a
</span><a href="GHC.Data.Bag.html#catBagMaybes"><span class="hs-identifier hs-var">catBagMaybes</span></a></span><span> </span><span class="annot"><span class="annottext">(Bag (Maybe Ct) -&gt; Cts) -&gt; TcS (Bag (Maybe Ct)) -&gt; TcS Cts
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; TcS (Maybe Ct)) -&gt; Cts -&gt; TcS (Bag (Maybe Ct))
forall (m :: * -&gt; *) a b.
Monad m =&gt;
(a -&gt; m b) -&gt; Bag a -&gt; m (Bag b)
</span><a href="GHC.Data.Bag.html#mapBagM"><span class="hs-identifier hs-var">mapBagM</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcS (Maybe Ct)
</span><a href="#local-6989586621681101763"><span class="hs-identifier hs-var">defaultCallStack</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101764"><span class="hs-identifier hs-var">simples</span></a></span><span>
</span><span id="line-401"></span><span>
</span><span id="line-402"></span><span>  </span><span class="annot"><a href="#local-6989586621681101769"><span class="hs-identifier hs-type">handle_implic</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-403"></span><span>  </span><span class="hs-comment">-- The Maybe is because solving the CallStack constraint</span><span>
</span><span id="line-404"></span><span>  </span><span class="hs-comment">-- may well allow us to discard the implication entirely</span><span>
</span><span id="line-405"></span><span>  </span><span id="local-6989586621681101769"><span class="annot"><span class="annottext">handle_implic :: Implication -&gt; TcS (Maybe Implication)
</span><a href="#local-6989586621681101769"><span class="hs-identifier hs-var hs-var">handle_implic</span></a></span></span><span> </span><span id="local-6989586621681101762"><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101762"><span class="hs-identifier hs-var">implic</span></a></span></span><span>
</span><span id="line-406"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">ImplicStatus -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isSolvedStatus"><span class="hs-identifier hs-var">isSolvedStatus</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication -&gt; ImplicStatus
</span><a href="GHC.Tc.Types.Constraint.html#ic_status"><span class="hs-identifier hs-var hs-var">ic_status</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101762"><span class="hs-identifier hs-var">implic</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-407"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Implication -&gt; TcS (Maybe Implication)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication -&gt; Maybe Implication
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101762"><span class="hs-identifier hs-var">implic</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-408"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-409"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101760"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101760"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; TcS WantedConstraints -&gt; TcS WantedConstraints
forall a. EvBindsVar -&gt; TcS a -&gt; TcS a
</span><a href="GHC.Tc.Solver.Monad.html#setEvBindsTcS"><span class="hs-identifier hs-var">setEvBindsTcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication -&gt; EvBindsVar
</span><a href="GHC.Tc.Types.Constraint.html#ic_binds"><span class="hs-identifier hs-var hs-var">ic_binds</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101762"><span class="hs-identifier hs-var">implic</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcS WantedConstraints -&gt; TcS WantedConstraints)
-&gt; TcS WantedConstraints -&gt; TcS WantedConstraints
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-410"></span><span>                      </span><span class="hs-comment">-- defaultCallStack sets a binding, so</span><span>
</span><span id="line-411"></span><span>                      </span><span class="hs-comment">-- we must set the correct binding group</span><span>
</span><span id="line-412"></span><span>                      </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#defaultCallStacks"><span class="hs-identifier hs-var">defaultCallStacks</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var hs-var">ic_wanted</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101762"><span class="hs-identifier hs-var">implic</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-413"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Implication -&gt; TcS (Maybe Implication)
</span><a href="GHC.Tc.Solver.html#setImplicationStatus"><span class="hs-identifier hs-var">setImplicationStatus</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101762"><span class="hs-identifier hs-var">implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101760"><span class="hs-identifier hs-var">wanteds</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-414"></span><span>
</span><span id="line-415"></span><span>  </span><span id="local-6989586621681101763"><span class="annot"><span class="annottext">defaultCallStack :: Ct -&gt; TcS (Maybe Ct)
</span><a href="#local-6989586621681101763"><span class="hs-identifier hs-var hs-var">defaultCallStack</span></a></span></span><span> </span><span id="local-6989586621681101753"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101753"><span class="hs-identifier hs-var">ct</span></a></span></span><span>
</span><span id="line-416"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#ClassPred"><span class="hs-identifier hs-type">ClassPred</span></a></span><span> </span><span id="local-6989586621681101751"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101751"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681101750"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101750"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Pred
</span><a href="GHC.Core.Predicate.html#classifyPredType"><span class="hs-identifier hs-var">classifyPredType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ct -&gt; Type
</span><a href="GHC.Tc.Types.Constraint.html#ctPred"><span class="hs-identifier hs-var">ctPred</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101753"><span class="hs-identifier hs-var">ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-417"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Class -&gt; [Type] -&gt; Maybe FastString
</span><a href="GHC.Tc.Utils.TcType.html#isCallStackPred"><span class="hs-identifier hs-var">isCallStackPred</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101751"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101750"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-418"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; EvCallStack -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Canonical.html#solveCallStack"><span class="hs-identifier hs-var">solveCallStack</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ct -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#ctEvidence"><span class="hs-identifier hs-var">ctEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101753"><span class="hs-identifier hs-var">ct</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">EvCallStack
</span><a href="GHC.Tc.Types.Evidence.html#EvCsEmpty"><span class="hs-identifier hs-var">EvCsEmpty</span></a></span><span>
</span><span id="line-419"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe Ct -&gt; TcS (Maybe Ct)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Ct
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-420"></span><span>
</span><span id="line-421"></span><span>  </span><span class="annot"><a href="#local-6989586621681101763"><span class="hs-identifier hs-var">defaultCallStack</span></a></span><span> </span><span id="local-6989586621681101744"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101744"><span class="hs-identifier hs-var">ct</span></a></span></span><span>
</span><span id="line-422"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Ct -&gt; TcS (Maybe Ct)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ct -&gt; Maybe Ct
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101744"><span class="hs-identifier hs-var">ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-423"></span><span>
</span><span id="line-424"></span><span>
</span><span id="line-425"></span><span class="hs-comment">{- Note [Fail fast on kind errors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
solveEqualities is used to solve kind equalities when kind-checking
user-written types. If solving fails we should fail outright, rather
than just accumulate an error message, for two reasons:

  * A kind-bogus type signature may cause a cascade of knock-on
    errors if we let it pass

  * More seriously, we don't have a convenient term-level place to add
    deferred bindings for unsolved kind-equality constraints, so we
    don't build evidence bindings (by usine reportAllUnsolved). That
    means that we'll be left with a type that has coercion holes
    in it, something like
           &lt;type&gt; |&gt; co-hole
    where co-hole is not filled in.  Eeek!  That un-filled-in
    hole actually causes GHC to crash with &quot;fvProv falls into a hole&quot;
    See #11563, #11520, #11516, #11399

So it's important to use 'checkNoErrs' here!

Note [When to do type-class defaulting]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In GHC 7.6 and 7.8.2, we did type-class defaulting only if insolubleWC
was false, on the grounds that defaulting can't help solve insoluble
constraints.  But if we *don't* do defaulting we may report a whole
lot of errors that would be solved by defaulting; these errors are
quite spurious because fixing the single insoluble error means that
defaulting happens again, which makes all the other errors go away.
This is jolly confusing: #9033.

So it seems better to always do type-class defaulting.

However, always doing defaulting does mean that we'll do it in
situations like this (#5934):
   run :: (forall s. GenST s) -&gt; Int
   run = fromInteger 0
We don't unify the return type of fromInteger with the given function
type, because the latter involves foralls.  So we're left with
    (Num alpha, alpha ~ (forall s. GenST s) -&gt; Int)
Now we do defaulting, get alpha := Integer, and report that we can't
match Integer with (forall s. GenST s) -&gt; Int.  That's not totally
stupid, but perhaps a little strange.

Another potential alternative would be to suppress *all* non-insoluble
errors if there are *any* insoluble errors, anywhere, but that seems
too drastic.

Note [Must simplify after defaulting]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We may have a deeply buried constraint
    (t:*) ~ (a:Open)
which we couldn't solve because of the kind incompatibility, and 'a' is free.
Then when we default 'a' we can solve the constraint.  And we want to do
that before starting in on type classes.  We MUST do it before reporting
errors, because it isn't an error!  #7967 was due to this.

Note [Top-level Defaulting Plan]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We have considered two design choices for where/when to apply defaulting.
   (i) Do it in SimplCheck mode only /whenever/ you try to solve some
       simple constraints, maybe deep inside the context of implications.
       This used to be the case in GHC 7.4.1.
   (ii) Do it in a tight loop at simplifyTop, once all other constraints have
        finished. This is the current story.

Option (i) had many disadvantages:
   a) Firstly, it was deep inside the actual solver.
   b) Secondly, it was dependent on the context (Infer a type signature,
      or Check a type signature, or Interactive) since we did not want
      to always start defaulting when inferring (though there is an exception to
      this, see Note [Default while Inferring]).
   c) It plainly did not work. Consider typecheck/should_compile/DfltProb2.hs:
          f :: Int -&gt; Bool
          f x = const True (\y -&gt; let w :: a -&gt; a
                                      w a = const a (y+1)
                                  in w y)
      We will get an implication constraint (for beta the type of y):
               [untch=beta] forall a. 0 =&gt; Num beta
      which we really cannot default /while solving/ the implication, since beta is
      untouchable.

Instead our new defaulting story is to pull defaulting out of the solver loop and
go with option (ii), implemented at SimplifyTop. Namely:
     - First, have a go at solving the residual constraint of the whole
       program
     - Try to approximate it with a simple constraint
     - Figure out derived defaulting equations for that simple constraint
     - Go round the loop again if you did manage to get some equations

Now, that has to do with class defaulting. However there exists type variable /kind/
defaulting. Again this is done at the top-level and the plan is:
     - At the top-level, once you had a go at solving the constraint, do
       figure out /all/ the touchable unification variables of the wanted constraints.
     - Apply defaulting to their kinds

More details in Note [DefaultTyVar].

Note [Safe Haskell Overlapping Instances]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In Safe Haskell, we apply an extra restriction to overlapping instances. The
motive is to prevent untrusted code provided by a third-party, changing the
behavior of trusted code through type-classes. This is due to the global and
implicit nature of type-classes that can hide the source of the dictionary.

Another way to state this is: if a module M compiles without importing another
module N, changing M to import N shouldn't change the behavior of M.

Overlapping instances with type-classes can violate this principle. However,
overlapping instances aren't always unsafe. They are just unsafe when the most
selected dictionary comes from untrusted code (code compiled with -XSafe) and
overlaps instances provided by other modules.

In particular, in Safe Haskell at a call site with overlapping instances, we
apply the following rule to determine if it is a 'unsafe' overlap:

 1) Most specific instance, I1, defined in an `-XSafe` compiled module.
 2) I1 is an orphan instance or a MPTC.
 3) At least one overlapped instance, Ix, is both:
    A) from a different module than I1
    B) Ix is not marked `OVERLAPPABLE`

This is a slightly involved heuristic, but captures the situation of an
imported module N changing the behavior of existing code. For example, if
condition (2) isn't violated, then the module author M must depend either on a
type-class or type defined in N.

Secondly, when should these heuristics be enforced? We enforced them when the
type-class method call site is in a module marked `-XSafe` or `-XTrustworthy`.
This allows `-XUnsafe` modules to operate without restriction, and for Safe
Haskell inferrence to infer modules with unsafe overlaps as unsafe.

One alternative design would be to also consider if an instance was imported as
a `safe` import or not and only apply the restriction to instances imported
safely. However, since instances are global and can be imported through more
than one path, this alternative doesn't work.

Note [Safe Haskell Overlapping Instances Implementation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

How is this implemented? It's complicated! So we'll step through it all:

 1) `InstEnv.lookupInstEnv` -- Performs instance resolution, so this is where
    we check if a particular type-class method call is safe or unsafe. We do this
    through the return type, `ClsInstLookupResult`, where the last parameter is a
    list of instances that are unsafe to overlap. When the method call is safe,
    the list is null.

 2) `GHC.Tc.Solver.Interact.matchClassInst` -- This module drives the instance resolution
    / dictionary generation. The return type is `ClsInstResult`, which either
    says no instance matched, or one found, and if it was a safe or unsafe
    overlap.

 3) `GHC.Tc.Solver.Interact.doTopReactDict` -- Takes a dictionary / class constraint and
     tries to resolve it by calling (in part) `matchClassInst`. The resolving
     mechanism has a work list (of constraints) that it process one at a time. If
     the constraint can't be resolved, it's added to an inert set. When compiling
     an `-XSafe` or `-XTrustworthy` module, we follow this approach as we know
     compilation should fail. These are handled as normal constraint resolution
     failures from here-on (see step 6).

     Otherwise, we may be inferring safety (or using `-Wunsafe`), and
     compilation should succeed, but print warnings and/or mark the compiled module
     as `-XUnsafe`. In this case, we call `insertSafeOverlapFailureTcS` which adds
     the unsafe (but resolved!) constraint to the `inert_safehask` field of
     `InertCans`.

 4) `GHC.Tc.Solver.simplifyTop`:
       * Call simpl_top, the top-level function for driving the simplifier for
         constraint resolution.

       * Once finished, call `getSafeOverlapFailures` to retrieve the
         list of overlapping instances that were successfully resolved,
         but unsafe. Remember, this is only applicable for generating warnings
         (`-Wunsafe`) or inferring a module unsafe. `-XSafe` and `-XTrustworthy`
         cause compilation failure by not resolving the unsafe constraint at all.

       * For unresolved constraints (all types), call `GHC.Tc.Errors.reportUnsolved`,
         while for resolved but unsafe overlapping dictionary constraints, call
         `GHC.Tc.Errors.warnAllUnsolved`. Both functions convert constraints into a
         warning message for the user.

       * In the case of `warnAllUnsolved` for resolved, but unsafe
         dictionary constraints, we collect the generated warning
         message (pop it) and call `GHC.Tc.Utils.Monad.recordUnsafeInfer` to
         mark the module we are compiling as unsafe, passing the
         warning message along as the reason.

 5) `GHC.Tc.Errors.*Unsolved` -- Generates error messages for constraints by
    actually calling `InstEnv.lookupInstEnv` again! Yes, confusing, but all we
    know is the constraint that is unresolved or unsafe. For dictionary, all we
    know is that we need a dictionary of type C, but not what instances are
    available and how they overlap. So we once again call `lookupInstEnv` to
    figure that out so we can generate a helpful error message.

 6) `GHC.Tc.Utils.Monad.recordUnsafeInfer` -- Save the unsafe result and reason in an
      IORef called `tcg_safeInfer`.

 7) `GHC.Driver.Main.tcRnModule'` -- Reads `tcg_safeInfer` after type-checking, calling
    `GHC.Driver.Main.markUnsafeInfer` (passing the reason along) when safe-inferrence
    failed.

Note [No defaulting in the ambiguity check]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When simplifying constraints for the ambiguity check, we use
solveWantedsAndDrop, not simpl_top, so that we do no defaulting.
#11947 was an example:
   f :: Num a =&gt; Int -&gt; Int
This is ambiguous of course, but we don't want to default the
(Num alpha) constraint to (Num Int)!  Doing so gives a defaulting
warning, but no error.

Note [Defaulting insolubles]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If a set of wanteds is insoluble, we have no hope of accepting the
program. Yet we do not stop constraint solving, etc., because we may
simplify the wanteds to produce better error messages. So, once
we have an insoluble constraint, everything we do is just about producing
helpful error messages.

Should we default in this case or not? Let's look at an example (tcfail004):

  (f,g) = (1,2,3)

With defaulting, we get a conflict between (a0,b0) and (Integer,Integer,Integer).
Without defaulting, we get a conflict between (a0,b0) and (a1,b1,c1). I (Richard)
find the latter more helpful. Several other test cases (e.g. tcfail005) suggest
similarly. So: we should not do class defaulting with insolubles.

On the other hand, RuntimeRep-defaulting is different. Witness tcfail078:

  f :: Integer i =&gt; i
  f =               0

Without RuntimeRep-defaulting, we GHC suggests that Integer should have kind
TYPE r0 -&gt; Constraint and then complains that r0 is actually untouchable
(presumably, because it can't be sure if `Integer i` entails an equality).
If we default, we are told of a clash between (* -&gt; Constraint) and Constraint.
The latter seems far better, suggesting we *should* do RuntimeRep-defaulting
even on insolubles.

But, evidently, not always. Witness UnliftedNewtypesInfinite:

  newtype Foo = FooC (# Int#, Foo #)

This should fail with an occurs-check error on the kind of Foo (with -XUnliftedNewtypes).
If we default RuntimeRep-vars, we get

  Expecting a lifted type, but &#8216;(# Int#, Foo #)&#8217; is unlifted

which is just plain wrong.

Conclusion: we should do RuntimeRep-defaulting on insolubles only when the user does not
want to hear about RuntimeRep stuff -- that is, when -fprint-explicit-runtime-reps
is not set.
-}</span><span>
</span><span id="line-681"></span><span>
</span><span id="line-682"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-683"></span><span class="annot"><a href="GHC.Tc.Solver.html#simplifyAmbiguityCheck"><span class="hs-identifier hs-type">simplifyAmbiguityCheck</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-684"></span><span id="simplifyAmbiguityCheck"><span class="annot"><span class="annottext">simplifyAmbiguityCheck :: Type -&gt; WantedConstraints -&gt; TcM ()
</span><a href="GHC.Tc.Solver.html#simplifyAmbiguityCheck"><span class="hs-identifier hs-var hs-var">simplifyAmbiguityCheck</span></a></span></span><span> </span><span id="local-6989586621681101743"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101743"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681101742"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101742"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span>
</span><span id="line-685"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;simplifyAmbiguityCheck {&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;type = &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101743"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;wanted = &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101742"><span class="hs-identifier hs-var">wanteds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-686"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101740"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101740"><span class="hs-identifier hs-var">final_wc</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">EvBindMap
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS WantedConstraints -&gt; TcM (WantedConstraints, EvBindMap)
forall a. TcS a -&gt; TcM (a, EvBindMap)
</span><a href="GHC.Tc.Solver.Monad.html#runTcS"><span class="hs-identifier hs-var">runTcS</span></a></span><span> </span><span class="annot"><span class="annottext">(TcS WantedConstraints -&gt; TcM (WantedConstraints, EvBindMap))
-&gt; TcS WantedConstraints -&gt; TcM (WantedConstraints, EvBindMap)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#solveWantedsAndDrop"><span class="hs-identifier hs-var">solveWantedsAndDrop</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101742"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-687"></span><span>             </span><span class="hs-comment">-- NB: no defaulting!  See Note [No defaulting in the ambiguity check]</span><span>
</span><span id="line-688"></span><span>
</span><span id="line-689"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;End simplifyAmbiguityCheck }&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-690"></span><span>
</span><span id="line-691"></span><span>       </span><span class="hs-comment">-- Normally report all errors; but with -XAllowAmbiguousTypes</span><span>
</span><span id="line-692"></span><span>       </span><span class="hs-comment">-- report only insoluble ones, since they represent genuinely</span><span>
</span><span id="line-693"></span><span>       </span><span class="hs-comment">-- inaccessible code</span><span>
</span><span id="line-694"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101739"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101739"><span class="hs-identifier hs-var">allow_ambiguous</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcM Bool
forall gbl lcl. Extension -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#xoptM"><span class="hs-identifier hs-var">xoptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#AllowAmbiguousTypes"><span class="hs-identifier hs-var">LangExt.AllowAmbiguousTypes</span></a></span><span>
</span><span id="line-695"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;reportUnsolved(ambig) {&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-696"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcM () -&gt; TcM ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101739"><span class="hs-identifier hs-var">allow_ambiguous</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#insolubleWC"><span class="hs-identifier hs-var">insolubleWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101740"><span class="hs-identifier hs-var">final_wc</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-697"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcM (Bag EvBind) -&gt; TcM ()
forall a. TcM a -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#discardResult"><span class="hs-identifier hs-var">discardResult</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcM (Bag EvBind)
</span><a href="GHC.Tc.Errors.html#reportUnsolved"><span class="hs-identifier hs-var">reportUnsolved</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101740"><span class="hs-identifier hs-var">final_wc</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-698"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;reportUnsolved(ambig) }&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-699"></span><span>
</span><span id="line-700"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-701"></span><span>
</span><span id="line-702"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-703"></span><span class="annot"><a href="GHC.Tc.Solver.html#simplifyInteractive"><span class="hs-identifier hs-type">simplifyInteractive</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#EvBind"><span class="hs-identifier hs-type">EvBind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-704"></span><span id="simplifyInteractive"><span class="annot"><span class="annottext">simplifyInteractive :: WantedConstraints -&gt; TcM (Bag EvBind)
</span><a href="GHC.Tc.Solver.html#simplifyInteractive"><span class="hs-identifier hs-var hs-var">simplifyInteractive</span></a></span></span><span> </span><span id="local-6989586621681101735"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101735"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span>
</span><span id="line-705"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;simplifyInteractive&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span> </span><span class="annot"><span class="annottext">TcM () -&gt; TcM (Bag EvBind) -&gt; TcM (Bag EvBind)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span>
</span><span id="line-706"></span><span>    </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcM (Bag EvBind)
</span><a href="GHC.Tc.Solver.html#simplifyTop"><span class="hs-identifier hs-var">simplifyTop</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101735"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-707"></span><span>
</span><span id="line-708"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-709"></span><span class="annot"><a href="GHC.Tc.Solver.html#simplifyDefault"><span class="hs-identifier hs-type">simplifyDefault</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span>    </span><span class="hs-comment">-- Wanted; has no type variables in it</span><span>
</span><span id="line-710"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>       </span><span class="hs-comment">-- Succeeds if the constraint is soluble</span><span>
</span><span id="line-711"></span><span id="simplifyDefault"><span class="annot"><span class="annottext">simplifyDefault :: [Type] -&gt; TcM ()
</span><a href="GHC.Tc.Solver.html#simplifyDefault"><span class="hs-identifier hs-var hs-var">simplifyDefault</span></a></span></span><span> </span><span id="local-6989586621681101733"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101733"><span class="hs-identifier hs-var">theta</span></a></span></span><span>
</span><span id="line-712"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;simplifyDefault&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-713"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101732"><span class="annot"><span class="annottext">[CtEvidence]
</span><a href="#local-6989586621681101732"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; [Type] -&gt; TcM [CtEvidence]
</span><a href="GHC.Tc.Utils.TcMType.html#newWanteds"><span class="hs-identifier hs-var">newWanteds</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#DefaultOrigin"><span class="hs-identifier hs-var">DefaultOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101733"><span class="hs-identifier hs-var">theta</span></a></span><span>
</span><span id="line-714"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101729"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101729"><span class="hs-identifier hs-var">unsolved</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS WantedConstraints -&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
forall a. TcS a -&gt; TcM a
</span><a href="GHC.Tc.Solver.Monad.html#runTcSDeriveds"><span class="hs-identifier hs-var">runTcSDeriveds</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#solveWantedsAndDrop"><span class="hs-identifier hs-var">solveWantedsAndDrop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CtEvidence] -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#mkSimpleWC"><span class="hs-identifier hs-var">mkSimpleWC</span></a></span><span> </span><span class="annot"><span class="annottext">[CtEvidence]
</span><a href="#local-6989586621681101732"><span class="hs-identifier hs-var">wanteds</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-715"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcM ()
</span><a href="GHC.Tc.Errors.html#reportAllUnsolved"><span class="hs-identifier hs-var">reportAllUnsolved</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101729"><span class="hs-identifier hs-var">unsolved</span></a></span><span>
</span><span id="line-716"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-717"></span><span>
</span><span id="line-718"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-719"></span><span class="annot"><a href="GHC.Tc.Solver.html#tcCheckSatisfiability"><span class="hs-identifier hs-type">tcCheckSatisfiability</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-720"></span><span class="hs-comment">-- Return True if satisfiable, False if definitely contradictory</span><span>
</span><span id="line-721"></span><span id="tcCheckSatisfiability"><span class="annot"><span class="annottext">tcCheckSatisfiability :: Bag TcTyVar -&gt; TcM Bool
</span><a href="GHC.Tc.Solver.html#tcCheckSatisfiability"><span class="hs-identifier hs-var hs-var">tcCheckSatisfiability</span></a></span></span><span> </span><span id="local-6989586621681101726"><span class="annot"><span class="annottext">Bag TcTyVar
</span><a href="#local-6989586621681101726"><span class="hs-identifier hs-var">given_ids</span></a></span></span><span>
</span><span id="line-722"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101725"><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681101725"><span class="hs-identifier hs-var">lcl_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcLclEnv
forall gbl lcl. TcRnIf gbl lcl lcl
</span><a href="GHC.Tc.Utils.Monad.html#getLclEnv"><span class="hs-identifier hs-var">TcM.getLclEnv</span></a></span><span>
</span><span id="line-723"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101723"><span class="annot"><span class="annottext">given_loc :: CtLoc
</span><a href="#local-6989586621681101723"><span class="hs-identifier hs-var hs-var">given_loc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; SkolemInfo -&gt; TcLclEnv -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#mkGivenLoc"><span class="hs-identifier hs-var">mkGivenLoc</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#topTcLevel"><span class="hs-identifier hs-var">topTcLevel</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#UnkSkol"><span class="hs-identifier hs-var">UnkSkol</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681101725"><span class="hs-identifier hs-var">lcl_env</span></a></span><span>
</span><span id="line-724"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101719"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101719"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101718"><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101718"><span class="hs-identifier hs-var">_ev_binds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS Bool -&gt; TcM (Bool, EvBindMap)
forall a. TcS a -&gt; TcM (a, EvBindMap)
</span><a href="GHC.Tc.Solver.Monad.html#runTcS"><span class="hs-identifier hs-var">runTcS</span></a></span><span> </span><span class="annot"><span class="annottext">(TcS Bool -&gt; TcM (Bool, EvBindMap))
-&gt; TcS Bool -&gt; TcM (Bool, EvBindMap)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-725"></span><span>             </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;checkSatisfiability {&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag TcTyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bag TcTyVar
</span><a href="#local-6989586621681101726"><span class="hs-identifier hs-var">given_ids</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-726"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101716"><span class="annot"><span class="annottext">given_cts :: [Ct]
</span><a href="#local-6989586621681101716"><span class="hs-identifier hs-var hs-var">given_cts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; [TcTyVar] -&gt; [Ct]
</span><a href="GHC.Tc.Types.Constraint.html#mkGivens"><span class="hs-identifier hs-var">mkGivens</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681101723"><span class="hs-identifier hs-var">given_loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag TcTyVar -&gt; [TcTyVar]
forall a. Bag a -&gt; [a]
</span><a href="GHC.Data.Bag.html#bagToList"><span class="hs-identifier hs-var">bagToList</span></a></span><span> </span><span class="annot"><span class="annottext">Bag TcTyVar
</span><a href="#local-6989586621681101726"><span class="hs-identifier hs-var">given_ids</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-727"></span><span>                     </span><span class="hs-comment">-- See Note [Superclasses and satisfiability]</span><span>
</span><span id="line-728"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Interact.html#solveSimpleGivens"><span class="hs-identifier hs-var">solveSimpleGivens</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101716"><span class="hs-identifier hs-var">given_cts</span></a></span><span>
</span><span id="line-729"></span><span>                </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101712"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101712"><span class="hs-identifier hs-var">insols</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS Cts
</span><a href="GHC.Tc.Solver.Monad.html#getInertInsols"><span class="hs-identifier hs-var">getInertInsols</span></a></span><span>
</span><span id="line-730"></span><span>                </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101710"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101710"><span class="hs-identifier hs-var">insols</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Cts -&gt; TcS Cts
</span><a href="#local-6989586621681101709"><span class="hs-identifier hs-var">try_harder</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101712"><span class="hs-identifier hs-var">insols</span></a></span><span>
</span><span id="line-731"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;checkSatisfiability }&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101710"><span class="hs-identifier hs-var">insols</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-732"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcS Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts -&gt; Bool
forall a. Bag a -&gt; Bool
</span><a href="GHC.Data.Bag.html#isEmptyBag"><span class="hs-identifier hs-var">isEmptyBag</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101710"><span class="hs-identifier hs-var">insols</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-733"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcM Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101719"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-734"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-735"></span><span>    </span><span class="annot"><a href="#local-6989586621681101709"><span class="hs-identifier hs-type">try_harder</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Cts"><span class="hs-identifier hs-type">Cts</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Cts"><span class="hs-identifier hs-type">Cts</span></a></span><span>
</span><span id="line-736"></span><span>    </span><span class="hs-comment">-- Maybe we have to search up the superclass chain to find</span><span>
</span><span id="line-737"></span><span>    </span><span class="hs-comment">-- an unsatisfiable constraint.  Example: pmcheck/T3927b.</span><span>
</span><span id="line-738"></span><span>    </span><span class="hs-comment">-- At the moment we try just once</span><span>
</span><span id="line-739"></span><span>    </span><span id="local-6989586621681101709"><span class="annot"><span class="annottext">try_harder :: Cts -&gt; TcS Cts
</span><a href="#local-6989586621681101709"><span class="hs-identifier hs-var hs-var">try_harder</span></a></span></span><span> </span><span id="local-6989586621681101708"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101708"><span class="hs-identifier hs-var">insols</span></a></span></span><span>
</span><span id="line-740"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts -&gt; Bool
forall a. Bag a -&gt; Bool
</span><a href="GHC.Data.Bag.html#isEmptyBag"><span class="hs-identifier hs-var">isEmptyBag</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101708"><span class="hs-identifier hs-var">insols</span></a></span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- We've found that it's definitely unsatisfiable</span><span>
</span><span id="line-741"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts -&gt; TcS Cts
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101708"><span class="hs-identifier hs-var">insols</span></a></span><span>             </span><span class="hs-comment">-- Hurrah -- stop now.</span><span>
</span><span id="line-742"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-743"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101707"><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101707"><span class="hs-identifier hs-var">pending_given</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS [Ct]
</span><a href="GHC.Tc.Solver.Monad.html#getPendingGivenScs"><span class="hs-identifier hs-var">getPendingGivenScs</span></a></span><span>
</span><span id="line-744"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101705"><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101705"><span class="hs-identifier hs-var">new_given</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#makeSuperClasses"><span class="hs-identifier hs-var">makeSuperClasses</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101707"><span class="hs-identifier hs-var">pending_given</span></a></span><span>
</span><span id="line-745"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Interact.html#solveSimpleGivens"><span class="hs-identifier hs-var">solveSimpleGivens</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101705"><span class="hs-identifier hs-var">new_given</span></a></span><span>
</span><span id="line-746"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcS Cts
</span><a href="GHC.Tc.Solver.Monad.html#getInertInsols"><span class="hs-identifier hs-var">getInertInsols</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-747"></span><span>
</span><span id="line-748"></span><span class="hs-comment">-- | Normalise a type as much as possible using the given constraints.</span><span>
</span><span id="line-749"></span><span class="hs-comment">-- See @Note [tcNormalise]@.</span><span>
</span><span id="line-750"></span><span class="annot"><a href="GHC.Tc.Solver.html#tcNormalise"><span class="hs-identifier hs-type">tcNormalise</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-751"></span><span id="tcNormalise"><span class="annot"><span class="annottext">tcNormalise :: Bag TcTyVar -&gt; Type -&gt; TcM Type
</span><a href="GHC.Tc.Solver.html#tcNormalise"><span class="hs-identifier hs-var hs-var">tcNormalise</span></a></span></span><span> </span><span id="local-6989586621681101704"><span class="annot"><span class="annottext">Bag TcTyVar
</span><a href="#local-6989586621681101704"><span class="hs-identifier hs-var">given_ids</span></a></span></span><span> </span><span id="local-6989586621681101703"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101703"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-752"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101702"><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681101702"><span class="hs-identifier hs-var">lcl_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcLclEnv
forall gbl lcl. TcRnIf gbl lcl lcl
</span><a href="GHC.Tc.Utils.Monad.html#getLclEnv"><span class="hs-identifier hs-var">TcM.getLclEnv</span></a></span><span>
</span><span id="line-753"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101701"><span class="annot"><span class="annottext">given_loc :: CtLoc
</span><a href="#local-6989586621681101701"><span class="hs-identifier hs-var hs-var">given_loc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; SkolemInfo -&gt; TcLclEnv -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#mkGivenLoc"><span class="hs-identifier hs-var">mkGivenLoc</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#topTcLevel"><span class="hs-identifier hs-var">topTcLevel</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#UnkSkol"><span class="hs-identifier hs-var">UnkSkol</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681101702"><span class="hs-identifier hs-var">lcl_env</span></a></span><span>
</span><span id="line-754"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101700"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681101700"><span class="hs-identifier hs-var">norm_loc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; Maybe TypeOrKind -&gt; TcM CtLoc
</span><a href="GHC.Tc.Utils.Monad.html#getCtLocM"><span class="hs-identifier hs-var">getCtLocM</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#PatCheckOrigin"><span class="hs-identifier hs-var">PatCheckOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TypeOrKind
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-755"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101697"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101697"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101696"><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101696"><span class="hs-identifier hs-var">_ev_binds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS Type -&gt; TcM (Type, EvBindMap)
forall a. TcS a -&gt; TcM (a, EvBindMap)
</span><a href="GHC.Tc.Solver.Monad.html#runTcS"><span class="hs-identifier hs-var">runTcS</span></a></span><span> </span><span class="annot"><span class="annottext">(TcS Type -&gt; TcM (Type, EvBindMap))
-&gt; TcS Type -&gt; TcM (Type, EvBindMap)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-756"></span><span>             </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcNormalise {&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag TcTyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bag TcTyVar
</span><a href="#local-6989586621681101704"><span class="hs-identifier hs-var">given_ids</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-757"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101695"><span class="annot"><span class="annottext">given_cts :: [Ct]
</span><a href="#local-6989586621681101695"><span class="hs-identifier hs-var hs-var">given_cts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; [TcTyVar] -&gt; [Ct]
</span><a href="GHC.Tc.Types.Constraint.html#mkGivens"><span class="hs-identifier hs-var">mkGivens</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681101701"><span class="hs-identifier hs-var">given_loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag TcTyVar -&gt; [TcTyVar]
forall a. Bag a -&gt; [a]
</span><a href="GHC.Data.Bag.html#bagToList"><span class="hs-identifier hs-var">bagToList</span></a></span><span> </span><span class="annot"><span class="annottext">Bag TcTyVar
</span><a href="#local-6989586621681101704"><span class="hs-identifier hs-var">given_ids</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-758"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Interact.html#solveSimpleGivens"><span class="hs-identifier hs-var">solveSimpleGivens</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101695"><span class="hs-identifier hs-var">given_cts</span></a></span><span>
</span><span id="line-759"></span><span>                </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101694"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101694"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Type -&gt; TcS Type
</span><a href="GHC.Tc.Solver.Flatten.html#flattenType"><span class="hs-identifier hs-var">flattenType</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681101700"><span class="hs-identifier hs-var">norm_loc</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101703"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-760"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcNormalise }&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101694"><span class="hs-identifier hs-var">ty'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-761"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Type -&gt; TcS Type
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101694"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-762"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Type -&gt; TcM Type
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101697"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-763"></span><span>
</span><span id="line-764"></span><span class="hs-comment">{- Note [Superclasses and satisfiability]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand superclasses before starting, because (Int ~ Bool), has
(Int ~~ Bool) as a superclass, which in turn has (Int ~N# Bool)
as a superclass, and it's the latter that is insoluble.  See
Note [The equality types story] in GHC.Builtin.Types.Prim.

If we fail to prove unsatisfiability we (arbitrarily) try just once to
find superclasses, using try_harder.  Reason: we might have a type
signature
   f :: F op (Implements push) =&gt; ..
where F is a type function.  This happened in #3972.

We could do more than once but we'd have to have /some/ limit: in the
the recursive case, we would go on forever in the common case where
the constraints /are/ satisfiable (#10592 comment:12!).

For stratightforard situations without type functions the try_harder
step does nothing.

Note [tcNormalise]
~~~~~~~~~~~~~~~~~~
tcNormalise is a rather atypical entrypoint to the constraint solver. Whereas
most invocations of the constraint solver are intended to simplify a set of
constraints or to decide if a particular set of constraints is satisfiable,
the purpose of tcNormalise is to take a type, plus some local constraints, and
normalise the type as much as possible with respect to those constraints.

It does *not* reduce type or data family applications or look through newtypes.

Why is this useful? As one example, when coverage-checking an EmptyCase
expression, it's possible that the type of the scrutinee will only reduce
if some local equalities are solved for. See &quot;Wrinkle: Local equalities&quot;
in Note [Type normalisation] in &quot;GHC.HsToCore.PmCheck&quot;.

To accomplish its stated goal, tcNormalise first feeds the local constraints
into solveSimpleGivens, then uses flattenType to simplify the desired type
with respect to the givens.

***********************************************************************************
*                                                                                 *
*                            Inference
*                                                                                 *
***********************************************************************************

Note [Inferring the type of a let-bound variable]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
   f x = rhs

To infer f's type we do the following:
 * Gather the constraints for the RHS with ambient level *one more than*
   the current one.  This is done by the call
        pushLevelAndCaptureConstraints (tcMonoBinds...)
   in GHC.Tc.Gen.Bind.tcPolyInfer

 * Call simplifyInfer to simplify the constraints and decide what to
   quantify over. We pass in the level used for the RHS constraints,
   here called rhs_tclvl.

This ensures that the implication constraint we generate, if any,
has a strictly-increased level compared to the ambient level outside
the let binding.

-}</span><span>
</span><span id="line-829"></span><span>
</span><span id="line-830"></span><span class="hs-comment">-- | How should we choose which constraints to quantify over?</span><span>
</span><span id="line-831"></span><span class="hs-keyword">data</span><span> </span><span id="InferMode"><span class="annot"><a href="GHC.Tc.Solver.html#InferMode"><span class="hs-identifier hs-var">InferMode</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="ApplyMR"><span class="annot"><a href="GHC.Tc.Solver.html#ApplyMR"><span class="hs-identifier hs-var">ApplyMR</span></a></span></span><span>          </span><span class="hs-comment">-- ^ Apply the monomorphism restriction,</span><span>
</span><span id="line-832"></span><span>                                  </span><span class="hs-comment">-- never quantifying over any constraints</span><span>
</span><span id="line-833"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span id="EagerDefaulting"><span class="annot"><a href="GHC.Tc.Solver.html#EagerDefaulting"><span class="hs-identifier hs-var">EagerDefaulting</span></a></span></span><span>  </span><span class="hs-comment">-- ^ See Note [TcRnExprMode] in &quot;GHC.Tc.Module&quot;,</span><span>
</span><span id="line-834"></span><span>                                  </span><span class="hs-comment">-- the :type +d case; this mode refuses</span><span>
</span><span id="line-835"></span><span>                                  </span><span class="hs-comment">-- to quantify over any defaultable constraint</span><span>
</span><span id="line-836"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span id="NoRestrictions"><span class="annot"><a href="GHC.Tc.Solver.html#NoRestrictions"><span class="hs-identifier hs-var">NoRestrictions</span></a></span></span><span>   </span><span class="hs-comment">-- ^ Quantify over any constraint that</span><span>
</span><span id="line-837"></span><span>                                  </span><span class="hs-comment">-- satisfies 'GHC.Tc.Utils.TcType.pickQuantifiablePreds'</span><span>
</span><span id="line-838"></span><span>
</span><span id="line-839"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681101688"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Solver.html#InferMode"><span class="hs-identifier hs-type">InferMode</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-840"></span><span>  </span><span id="local-6989586621681101686"><span class="annot"><span class="annottext">ppr :: InferMode -&gt; SDoc
</span><a href="#local-6989586621681101686"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="annot"><span class="annottext">InferMode
</span><a href="GHC.Tc.Solver.html#ApplyMR"><span class="hs-identifier hs-var">ApplyMR</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ApplyMR&quot;</span></span><span>
</span><span id="line-841"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">InferMode
</span><a href="GHC.Tc.Solver.html#EagerDefaulting"><span class="hs-identifier hs-var">EagerDefaulting</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;EagerDefaulting&quot;</span></span><span>
</span><span id="line-842"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">InferMode
</span><a href="GHC.Tc.Solver.html#NoRestrictions"><span class="hs-identifier hs-var">NoRestrictions</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;NoRestrictions&quot;</span></span><span>
</span><span id="line-843"></span><span>
</span><span id="line-844"></span><span class="annot"><a href="GHC.Tc.Solver.html#simplifyInfer"><span class="hs-identifier hs-type">simplifyInfer</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcLevel"><span class="hs-identifier hs-type">TcLevel</span></a></span><span>               </span><span class="hs-comment">-- Used when generating the constraints</span><span>
</span><span id="line-845"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.html#InferMode"><span class="hs-identifier hs-type">InferMode</span></a></span><span>
</span><span id="line-846"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.html#TcIdSigInst"><span class="hs-identifier hs-type">TcIdSigInst</span></a></span><span class="hs-special">]</span><span>         </span><span class="hs-comment">-- Any signatures (possibly partial)</span><span>
</span><span id="line-847"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTauType"><span class="hs-identifier hs-type">TcTauType</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>   </span><span class="hs-comment">-- Variables to be generalised,</span><span>
</span><span id="line-848"></span><span>                                       </span><span class="hs-comment">-- and their tau-types</span><span>
</span><span id="line-849"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-850"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span>    </span><span class="hs-comment">-- Quantify over these type variables</span><span>
</span><span id="line-851"></span><span>                      </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span>      </span><span class="hs-comment">-- ... and these constraints (fully zonked)</span><span>
</span><span id="line-852"></span><span>                      </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcEvBinds"><span class="hs-identifier hs-type">TcEvBinds</span></a></span><span class="hs-special">,</span><span>    </span><span class="hs-comment">-- ... binding these evidence variables</span><span>
</span><span id="line-853"></span><span>                      </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-comment">-- Redidual as-yet-unsolved constraints</span><span>
</span><span id="line-854"></span><span>                      </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span>         </span><span class="hs-comment">-- True &lt;=&gt; the residual constraints are insoluble</span><span>
</span><span id="line-855"></span><span>
</span><span id="line-856"></span><span id="simplifyInfer"><span class="annot"><span class="annottext">simplifyInfer :: TcLevel
-&gt; InferMode
-&gt; [TcIdSigInst]
-&gt; [(Name, Type)]
-&gt; WantedConstraints
-&gt; TcM ([TcTyVar], [TcTyVar], TcEvBinds, WantedConstraints, Bool)
</span><a href="GHC.Tc.Solver.html#simplifyInfer"><span class="hs-identifier hs-var hs-var">simplifyInfer</span></a></span></span><span> </span><span id="local-6989586621681101684"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101684"><span class="hs-identifier hs-var">rhs_tclvl</span></a></span></span><span> </span><span id="local-6989586621681101683"><span class="annot"><span class="annottext">InferMode
</span><a href="#local-6989586621681101683"><span class="hs-identifier hs-var">infer_mode</span></a></span></span><span> </span><span id="local-6989586621681101682"><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101682"><span class="hs-identifier hs-var">sigs</span></a></span></span><span> </span><span id="local-6989586621681101681"><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101681"><span class="hs-identifier hs-var">name_taus</span></a></span></span><span> </span><span id="local-6989586621681101680"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101680"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span>
</span><span id="line-857"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isEmptyWC"><span class="hs-identifier hs-var">isEmptyWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101680"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-858"></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- When quantifying, we want to preserve any order of variables as they</span><span>
</span><span id="line-859"></span><span>          </span><span class="hs-comment">-- appear in partial signatures. cf. decideQuantifiedTyVars</span><span>
</span><span id="line-860"></span><span>          </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101679"><span class="annot"><span class="annottext">psig_tv_tys :: [Type]
</span><a href="#local-6989586621681101679"><span class="hs-identifier hs-var hs-var">psig_tv_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101677"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681101676"><span class="annot"><span class="annottext">TcIdSigInst
</span><a href="#local-6989586621681101676"><span class="hs-identifier hs-var">sig</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101675"><span class="hs-identifier hs-var">partial_sigs</span></a></span><span>
</span><span id="line-861"></span><span>                                          </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-type">Bndr</span></a></span><span> </span><span id="local-6989586621681101677"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101677"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="annot"><span class="annottext">Specificity
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcIdSigInst -&gt; [(Name, InvisTVBinder)]
</span><a href="GHC.Tc.Types.html#sig_inst_skols"><span class="hs-identifier hs-var hs-var">sig_inst_skols</span></a></span><span> </span><span class="annot"><span class="annottext">TcIdSigInst
</span><a href="#local-6989586621681101676"><span class="hs-identifier hs-var">sig</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-862"></span><span>              </span><span id="local-6989586621681101672"><span class="annot"><span class="annottext">psig_theta :: [Type]
</span><a href="#local-6989586621681101672"><span class="hs-identifier hs-var hs-var">psig_theta</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101671"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681101670"><span class="annot"><span class="annottext">TcIdSigInst
</span><a href="#local-6989586621681101670"><span class="hs-identifier hs-var">sig</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101675"><span class="hs-identifier hs-var">partial_sigs</span></a></span><span>
</span><span id="line-863"></span><span>                                   </span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101671"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101671"><span class="hs-identifier hs-var">pred</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcIdSigInst -&gt; [Type]
</span><a href="GHC.Tc.Types.html#sig_inst_theta"><span class="hs-identifier hs-var hs-var">sig_inst_theta</span></a></span><span> </span><span class="annot"><span class="annottext">TcIdSigInst
</span><a href="#local-6989586621681101670"><span class="hs-identifier hs-var">sig</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-864"></span><span>
</span><span id="line-865"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101668"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681101668"><span class="hs-identifier hs-var">dep_vars</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfTypes"><span class="hs-identifier hs-var">candidateQTyVarsOfTypes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101679"><span class="hs-identifier hs-var">psig_tv_tys</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; [Type]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101672"><span class="hs-identifier hs-var">psig_theta</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; [Type]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">((Name, Type) -&gt; Type) -&gt; [(Name, Type)] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Name, Type) -&gt; Type
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101681"><span class="hs-identifier hs-var">name_taus</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-866"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101666"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101666"><span class="hs-identifier hs-var">qtkvs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TcM [TcTyVar]
</span><a href="GHC.Tc.Utils.TcMType.html#quantifyTyVars"><span class="hs-identifier hs-var">quantifyTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681101668"><span class="hs-identifier hs-var">dep_vars</span></a></span><span>
</span><span id="line-867"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;simplifyInfer: empty WC&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Name, Type)] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101681"><span class="hs-identifier hs-var">name_taus</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101666"><span class="hs-identifier hs-var">qtkvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-868"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([TcTyVar], [TcTyVar], TcEvBinds, WantedConstraints, Bool)
-&gt; TcM ([TcTyVar], [TcTyVar], TcEvBinds, WantedConstraints, Bool)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101666"><span class="hs-identifier hs-var">qtkvs</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcEvBinds
</span><a href="GHC.Tc.Types.Evidence.html#emptyTcEvBinds"><span class="hs-identifier hs-var">emptyTcEvBinds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#emptyWC"><span class="hs-identifier hs-var">emptyWC</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-869"></span><span>
</span><span id="line-870"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-871"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;simplifyInfer {&quot;</span></span><span>  </span><span class="annot"><span class="annottext">(SDoc -&gt; TcM ()) -&gt; SDoc -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span>
</span><span id="line-872"></span><span>             </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;sigs =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TcIdSigInst] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101682"><span class="hs-identifier hs-var">sigs</span></a></span><span>
</span><span id="line-873"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;binds =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, Type)] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101681"><span class="hs-identifier hs-var">name_taus</span></a></span><span>
</span><span id="line-874"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;rhs_tclvl =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101684"><span class="hs-identifier hs-var">rhs_tclvl</span></a></span><span>
</span><span id="line-875"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;infer_mode =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">InferMode -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">InferMode
</span><a href="#local-6989586621681101683"><span class="hs-identifier hs-var">infer_mode</span></a></span><span>
</span><span id="line-876"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;(unzonked) wanted =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101680"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-877"></span><span>             </span><span class="hs-special">]</span><span>
</span><span id="line-878"></span><span>
</span><span id="line-879"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101662"><span class="annot"><span class="annottext">psig_theta :: [Type]
</span><a href="#local-6989586621681101662"><span class="hs-identifier hs-var hs-var">psig_theta</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcIdSigInst -&gt; [Type]) -&gt; [TcIdSigInst] -&gt; [Type]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="annot"><span class="annottext">TcIdSigInst -&gt; [Type]
</span><a href="GHC.Tc.Types.html#sig_inst_theta"><span class="hs-identifier hs-var hs-var">sig_inst_theta</span></a></span><span> </span><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101675"><span class="hs-identifier hs-var">partial_sigs</span></a></span><span>
</span><span id="line-880"></span><span>
</span><span id="line-881"></span><span>       </span><span class="hs-comment">-- First do full-blown solving</span><span>
</span><span id="line-882"></span><span>       </span><span class="hs-comment">-- NB: we must gather up all the bindings from doing</span><span>
</span><span id="line-883"></span><span>       </span><span class="hs-comment">-- this solving; hence (runTcSWithEvBinds ev_binds_var).</span><span>
</span><span id="line-884"></span><span>       </span><span class="hs-comment">-- And note that since there are nested implications,</span><span>
</span><span id="line-885"></span><span>       </span><span class="hs-comment">-- calling solveWanteds will side-effect their evidence</span><span>
</span><span id="line-886"></span><span>       </span><span class="hs-comment">-- bindings, so we can't just revert to the input</span><span>
</span><span id="line-887"></span><span>       </span><span class="hs-comment">-- constraint.</span><span>
</span><span id="line-888"></span><span>
</span><span id="line-889"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101660"><span class="annot"><span class="annottext">Env TcGblEnv TcLclEnv
</span><a href="#local-6989586621681101660"><span class="hs-identifier hs-var">tc_env</span></a></span></span><span>          </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) (Env TcGblEnv TcLclEnv)
forall env. IOEnv env env
</span><a href="GHC.Data.IOEnv.html#getEnv"><span class="hs-identifier hs-var">TcM.getEnv</span></a></span><span>
</span><span id="line-890"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101658"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101658"><span class="hs-identifier hs-var">ev_binds_var</span></a></span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM EvBindsVar
</span><a href="GHC.Tc.Utils.Monad.html#newTcEvBinds"><span class="hs-identifier hs-var">TcM.newTcEvBinds</span></a></span><span>
</span><span id="line-891"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101656"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101656"><span class="hs-identifier hs-var">psig_theta_vars</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcTyVar)
-&gt; [Type] -&gt; TcM [TcTyVar]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcTyVar
forall gbl lcl. Type -&gt; TcRnIf gbl lcl TcTyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newEvVar"><span class="hs-identifier hs-var">TcM.newEvVar</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101662"><span class="hs-identifier hs-var">psig_theta</span></a></span><span>
</span><span id="line-892"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101654"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101654"><span class="hs-identifier hs-var">wanted_transformed_incl_derivs</span></a></span></span><span>
</span><span id="line-893"></span><span>            </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcLevel
-&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
-&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
forall a. TcLevel -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#setTcLevel"><span class="hs-identifier hs-var">setTcLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101684"><span class="hs-identifier hs-var">rhs_tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">(TcRnIf TcGblEnv TcLclEnv WantedConstraints
 -&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints)
-&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
-&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-894"></span><span>               </span><span class="annot"><span class="annottext">EvBindsVar
-&gt; TcS WantedConstraints
-&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
forall a. EvBindsVar -&gt; TcS a -&gt; TcM a
</span><a href="GHC.Tc.Solver.Monad.html#runTcSWithEvBinds"><span class="hs-identifier hs-var">runTcSWithEvBinds</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101658"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span> </span><span class="annot"><span class="annottext">(TcS WantedConstraints
 -&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints)
-&gt; TcS WantedConstraints
-&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-895"></span><span>               </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101651"><span class="annot"><span class="annottext">loc :: CtLoc
</span><a href="#local-6989586621681101651"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; SkolemInfo -&gt; TcLclEnv -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#mkGivenLoc"><span class="hs-identifier hs-var">mkGivenLoc</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101684"><span class="hs-identifier hs-var">rhs_tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#UnkSkol"><span class="hs-identifier hs-var">UnkSkol</span></a></span><span> </span><span class="annot"><span class="annottext">(TcLclEnv -&gt; CtLoc) -&gt; TcLclEnv -&gt; CtLoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-896"></span><span>                                      </span><span class="annot"><span class="annottext">Env TcGblEnv TcLclEnv -&gt; TcLclEnv
forall gbl lcl. Env gbl lcl -&gt; lcl
</span><a href="GHC.Tc.Types.html#env_lcl"><span class="hs-identifier hs-var hs-var">env_lcl</span></a></span><span> </span><span class="annot"><span class="annottext">Env TcGblEnv TcLclEnv
</span><a href="#local-6989586621681101660"><span class="hs-identifier hs-var">tc_env</span></a></span><span>
</span><span id="line-897"></span><span>                        </span><span id="local-6989586621681101649"><span class="annot"><span class="annottext">psig_givens :: [Ct]
</span><a href="#local-6989586621681101649"><span class="hs-identifier hs-var hs-var">psig_givens</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; [TcTyVar] -&gt; [Ct]
</span><a href="GHC.Tc.Types.Constraint.html#mkGivens"><span class="hs-identifier hs-var">mkGivens</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681101651"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101656"><span class="hs-identifier hs-var">psig_theta_vars</span></a></span><span>
</span><span id="line-898"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">()
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Interact.html#solveSimpleGivens"><span class="hs-identifier hs-var">solveSimpleGivens</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101649"><span class="hs-identifier hs-var">psig_givens</span></a></span><span>
</span><span id="line-899"></span><span>                         </span><span class="hs-comment">-- See Note [Add signature contexts as givens]</span><span>
</span><span id="line-900"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#solveWanteds"><span class="hs-identifier hs-var">solveWanteds</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101680"><span class="hs-identifier hs-var">wanteds</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-901"></span><span>
</span><span id="line-902"></span><span>       </span><span class="hs-comment">-- Find quant_pred_candidates, the predicates that</span><span>
</span><span id="line-903"></span><span>       </span><span class="hs-comment">-- we'll consider quantifying over</span><span>
</span><span id="line-904"></span><span>       </span><span class="hs-comment">-- NB1: wanted_transformed does not include anything provable from</span><span>
</span><span id="line-905"></span><span>       </span><span class="hs-comment">--      the psig_theta; it's just the extra bit</span><span>
</span><span id="line-906"></span><span>       </span><span class="hs-comment">-- NB2: We do not do any defaulting when inferring a type, this can lead</span><span>
</span><span id="line-907"></span><span>       </span><span class="hs-comment">--      to less polymorphic types, see Note [Default while Inferring]</span><span>
</span><span id="line-908"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101648"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101648"><span class="hs-identifier hs-var">wanted_transformed_incl_derivs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
</span><a href="GHC.Tc.Utils.TcMType.html#zonkWC"><span class="hs-identifier hs-var">TcM.zonkWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101654"><span class="hs-identifier hs-var">wanted_transformed_incl_derivs</span></a></span><span>
</span><span id="line-909"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101647"><span class="annot"><span class="annottext">definite_error :: Bool
</span><a href="#local-6989586621681101647"><span class="hs-identifier hs-var hs-var">definite_error</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#insolubleWC"><span class="hs-identifier hs-var">insolubleWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101648"><span class="hs-identifier hs-var">wanted_transformed_incl_derivs</span></a></span><span>
</span><span id="line-910"></span><span>                              </span><span class="hs-comment">-- See Note [Quantification with errors]</span><span>
</span><span id="line-911"></span><span>                              </span><span class="hs-comment">-- NB: must include derived errors in this test,</span><span>
</span><span id="line-912"></span><span>                              </span><span class="hs-comment">--     hence &quot;incl_derivs&quot;</span><span>
</span><span id="line-913"></span><span>             </span><span id="local-6989586621681101646"><span class="annot"><span class="annottext">wanted_transformed :: WantedConstraints
</span><a href="#local-6989586621681101646"><span class="hs-identifier hs-var hs-var">wanted_transformed</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#dropDerivedWC"><span class="hs-identifier hs-var">dropDerivedWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101648"><span class="hs-identifier hs-var">wanted_transformed_incl_derivs</span></a></span><span>
</span><span id="line-914"></span><span>             </span><span id="local-6989586621681101644"><span class="annot"><span class="annottext">quant_pred_candidates :: [Type]
</span><a href="#local-6989586621681101644"><span class="hs-identifier hs-var hs-var">quant_pred_candidates</span></a></span></span><span>
</span><span id="line-915"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101647"><span class="hs-identifier hs-var">definite_error</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-916"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts -&gt; [Type]
</span><a href="GHC.Tc.Solver.html#ctsPreds"><span class="hs-identifier hs-var">ctsPreds</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; WantedConstraints -&gt; Cts
</span><a href="GHC.Tc.Solver.html#approximateWC"><span class="hs-identifier hs-var">approximateWC</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101646"><span class="hs-identifier hs-var">wanted_transformed</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-917"></span><span>
</span><span id="line-918"></span><span>       </span><span class="hs-comment">-- Decide what type variables and constraints to quantify</span><span>
</span><span id="line-919"></span><span>       </span><span class="hs-comment">-- NB: quant_pred_candidates is already fully zonked</span><span>
</span><span id="line-920"></span><span>       </span><span class="hs-comment">-- NB: bound_theta are constraints we want to quantify over,</span><span>
</span><span id="line-921"></span><span>       </span><span class="hs-comment">--     including the psig_theta, which we always quantify over</span><span>
</span><span id="line-922"></span><span>       </span><span class="hs-comment">-- NB: bound_theta are fully zonked</span><span>
</span><span id="line-923"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101642"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101642"><span class="hs-identifier hs-var">qtvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101641"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101641"><span class="hs-identifier hs-var">bound_theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101640"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101640"><span class="hs-identifier hs-var">co_vars</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">InferMode
-&gt; TcLevel
-&gt; [(Name, Type)]
-&gt; [TcIdSigInst]
-&gt; [Type]
-&gt; TcM ([TcTyVar], [Type], VarSet)
</span><a href="GHC.Tc.Solver.html#decideQuantification"><span class="hs-identifier hs-var">decideQuantification</span></a></span><span> </span><span class="annot"><span class="annottext">InferMode
</span><a href="#local-6989586621681101683"><span class="hs-identifier hs-var">infer_mode</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101684"><span class="hs-identifier hs-var">rhs_tclvl</span></a></span><span>
</span><span id="line-924"></span><span>                                                     </span><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101681"><span class="hs-identifier hs-var">name_taus</span></a></span><span> </span><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101675"><span class="hs-identifier hs-var">partial_sigs</span></a></span><span>
</span><span id="line-925"></span><span>                                                     </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101644"><span class="hs-identifier hs-var">quant_pred_candidates</span></a></span><span>
</span><span id="line-926"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101638"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101638"><span class="hs-identifier hs-var">bound_theta_vars</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcTyVar)
-&gt; [Type] -&gt; TcM [TcTyVar]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcTyVar
forall gbl lcl. Type -&gt; TcRnIf gbl lcl TcTyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newEvVar"><span class="hs-identifier hs-var">TcM.newEvVar</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101641"><span class="hs-identifier hs-var">bound_theta</span></a></span><span>
</span><span id="line-927"></span><span>
</span><span id="line-928"></span><span>       </span><span class="hs-comment">-- We must produce bindings for the psig_theta_vars, because we may have</span><span>
</span><span id="line-929"></span><span>       </span><span class="hs-comment">-- used them in evidence bindings constructed by solveWanteds earlier</span><span>
</span><span id="line-930"></span><span>       </span><span class="hs-comment">-- Easiest way to do this is to emit them as new Wanteds (#14643)</span><span>
</span><span id="line-931"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101637"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681101637"><span class="hs-identifier hs-var">ct_loc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; Maybe TypeOrKind -&gt; TcM CtLoc
</span><a href="GHC.Tc.Utils.Monad.html#getCtLocM"><span class="hs-identifier hs-var">getCtLocM</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#AnnOrigin"><span class="hs-identifier hs-var">AnnOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TypeOrKind
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-932"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101635"><span class="annot"><span class="annottext">psig_wanted :: [CtEvidence]
</span><a href="#local-6989586621681101635"><span class="hs-identifier hs-var hs-var">psig_wanted</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">CtWanted :: Type -&gt; TcEvDest -&gt; ShadowInfo -&gt; CtLoc -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#CtWanted"><span class="hs-identifier hs-type">CtWanted</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: Type
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101632"><span class="hs-identifier hs-var">psig_theta_var</span></a></span><span>
</span><span id="line-933"></span><span>                                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_dest :: TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#ctev_dest"><span class="hs-identifier hs-var">ctev_dest</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#EvVarDest"><span class="hs-identifier hs-var">EvVarDest</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101632"><span class="hs-identifier hs-var">psig_theta_var</span></a></span><span>
</span><span id="line-934"></span><span>                                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_nosh :: ShadowInfo
</span><a href="GHC.Tc.Types.Constraint.html#ctev_nosh"><span class="hs-identifier hs-var">ctev_nosh</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ShadowInfo
</span><a href="GHC.Tc.Types.Constraint.html#WDeriv"><span class="hs-identifier hs-var">WDeriv</span></a></span><span>
</span><span id="line-935"></span><span>                                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_loc :: CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctev_loc"><span class="hs-identifier hs-var">ctev_loc</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681101637"><span class="hs-identifier hs-var">ct_loc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-936"></span><span>                           </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681101632"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101632"><span class="hs-identifier hs-var">psig_theta_var</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101656"><span class="hs-identifier hs-var">psig_theta_vars</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-937"></span><span>
</span><span id="line-938"></span><span>       </span><span class="hs-comment">-- Now construct the residual constraint</span><span>
</span><span id="line-939"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101626"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101626"><span class="hs-identifier hs-var">residual_wanted</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcLevel
-&gt; EvBindsVar
-&gt; [(Name, Type)]
-&gt; VarSet
-&gt; [TcTyVar]
-&gt; [TcTyVar]
-&gt; WantedConstraints
-&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
</span><a href="GHC.Tc.Solver.html#mkResidualConstraints"><span class="hs-identifier hs-var">mkResidualConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101684"><span class="hs-identifier hs-var">rhs_tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101658"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span>
</span><span id="line-940"></span><span>                                 </span><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101681"><span class="hs-identifier hs-var">name_taus</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101640"><span class="hs-identifier hs-var">co_vars</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101642"><span class="hs-identifier hs-var">qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101638"><span class="hs-identifier hs-var">bound_theta_vars</span></a></span><span>
</span><span id="line-941"></span><span>                                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101646"><span class="hs-identifier hs-var">wanted_transformed</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; WantedConstraints -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#andWC"><span class="hs-operator hs-var">`andWC`</span></a></span><span> </span><span class="annot"><span class="annottext">[CtEvidence] -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#mkSimpleWC"><span class="hs-identifier hs-var">mkSimpleWC</span></a></span><span> </span><span class="annot"><span class="annottext">[CtEvidence]
</span><a href="#local-6989586621681101635"><span class="hs-identifier hs-var">psig_wanted</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-942"></span><span>
</span><span id="line-943"></span><span>         </span><span class="hs-comment">-- All done!</span><span>
</span><span id="line-944"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;} simplifyInfer/produced residual implication for quantification&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcM ()) -&gt; SDoc -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-945"></span><span>         </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;quant_pred_candidates =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101644"><span class="hs-identifier hs-var">quant_pred_candidates</span></a></span><span>
</span><span id="line-946"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;psig_theta =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101662"><span class="hs-identifier hs-var">psig_theta</span></a></span><span>
</span><span id="line-947"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;bound_theta =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101641"><span class="hs-identifier hs-var">bound_theta</span></a></span><span>
</span><span id="line-948"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;qtvs =&quot;</span></span><span>       </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101642"><span class="hs-identifier hs-var">qtvs</span></a></span><span>
</span><span id="line-949"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;definite_error =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101647"><span class="hs-identifier hs-var">definite_error</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-950"></span><span>
</span><span id="line-951"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([TcTyVar], [TcTyVar], TcEvBinds, WantedConstraints, Bool)
-&gt; TcM ([TcTyVar], [TcTyVar], TcEvBinds, WantedConstraints, Bool)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101642"><span class="hs-identifier hs-var">qtvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101638"><span class="hs-identifier hs-var">bound_theta_vars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; TcEvBinds
</span><a href="GHC.Tc.Types.Evidence.html#TcEvBinds"><span class="hs-identifier hs-var">TcEvBinds</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101658"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span>
</span><span id="line-952"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101626"><span class="hs-identifier hs-var">residual_wanted</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101647"><span class="hs-identifier hs-var">definite_error</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-953"></span><span>         </span><span class="hs-comment">-- NB: bound_theta_vars must be fully zonked</span><span>
</span><span id="line-954"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-955"></span><span>    </span><span id="local-6989586621681101675"><span class="annot"><span class="annottext">partial_sigs :: [TcIdSigInst]
</span><a href="#local-6989586621681101675"><span class="hs-identifier hs-var hs-var">partial_sigs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcIdSigInst -&gt; Bool) -&gt; [TcIdSigInst] -&gt; [TcIdSigInst]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">TcIdSigInst -&gt; Bool
</span><a href="GHC.Tc.Types.html#isPartialSig"><span class="hs-identifier hs-var">isPartialSig</span></a></span><span> </span><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101682"><span class="hs-identifier hs-var">sigs</span></a></span><span>
</span><span id="line-956"></span><span>
</span><span id="line-957"></span><span class="hs-comment">--------------------</span><span>
</span><span id="line-958"></span><span class="annot"><a href="GHC.Tc.Solver.html#mkResidualConstraints"><span class="hs-identifier hs-type">mkResidualConstraints</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcLevel"><span class="hs-identifier hs-type">TcLevel</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#EvBindsVar"><span class="hs-identifier hs-type">EvBindsVar</span></a></span><span>
</span><span id="line-959"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTauType"><span class="hs-identifier hs-type">TcTauType</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-960"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-961"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-962"></span><span class="hs-comment">-- Emit the remaining constraints from the RHS.</span><span>
</span><span id="line-963"></span><span class="hs-comment">-- See Note [Emitting the residual implication in simplifyInfer]</span><span>
</span><span id="line-964"></span><span id="mkResidualConstraints"><span class="annot"><span class="annottext">mkResidualConstraints :: TcLevel
-&gt; EvBindsVar
-&gt; [(Name, Type)]
-&gt; VarSet
-&gt; [TcTyVar]
-&gt; [TcTyVar]
-&gt; WantedConstraints
-&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
</span><a href="GHC.Tc.Solver.html#mkResidualConstraints"><span class="hs-identifier hs-var hs-var">mkResidualConstraints</span></a></span></span><span> </span><span id="local-6989586621681101622"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101622"><span class="hs-identifier hs-var">rhs_tclvl</span></a></span></span><span> </span><span id="local-6989586621681101621"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101621"><span class="hs-identifier hs-var">ev_binds_var</span></a></span></span><span>
</span><span id="line-965"></span><span>                        </span><span id="local-6989586621681101620"><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101620"><span class="hs-identifier hs-var">name_taus</span></a></span></span><span> </span><span id="local-6989586621681101619"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101619"><span class="hs-identifier hs-var">co_vars</span></a></span></span><span> </span><span id="local-6989586621681101618"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101618"><span class="hs-identifier hs-var">qtvs</span></a></span></span><span> </span><span id="local-6989586621681101617"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101617"><span class="hs-identifier hs-var">full_theta_vars</span></a></span></span><span> </span><span id="local-6989586621681101616"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101616"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span>
</span><span id="line-966"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isEmptyWC"><span class="hs-identifier hs-var">isEmptyWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101616"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-967"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101616"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-968"></span><span>
</span><span id="line-969"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-970"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101615"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101615"><span class="hs-identifier hs-var">wanted_simple</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Cts -&gt; TcM Cts
</span><a href="GHC.Tc.Utils.TcMType.html#zonkSimples"><span class="hs-identifier hs-var">TcM.zonkSimples</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var hs-var">wc_simple</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101616"><span class="hs-identifier hs-var">wanteds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-971"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101613"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101613"><span class="hs-identifier hs-var">outer_simple</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101612"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101612"><span class="hs-identifier hs-var">inner_simple</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; Bool) -&gt; Cts -&gt; (Cts, Cts)
forall a. (a -&gt; Bool) -&gt; Bag a -&gt; (Bag a, Bag a)
</span><a href="GHC.Data.Bag.html#partitionBag"><span class="hs-identifier hs-var">partitionBag</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Bool
</span><a href="#local-6989586621681101610"><span class="hs-identifier hs-var">is_mono</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101615"><span class="hs-identifier hs-var">wanted_simple</span></a></span><span>
</span><span id="line-972"></span><span>             </span><span id="local-6989586621681101610"><span class="annot"><span class="annottext">is_mono :: Ct -&gt; Bool
</span><a href="#local-6989586621681101610"><span class="hs-identifier hs-var hs-var">is_mono</span></a></span></span><span> </span><span id="local-6989586621681101609"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101609"><span class="hs-identifier hs-var">ct</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isWantedCt"><span class="hs-identifier hs-var">isWantedCt</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101609"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcTyVar
</span><a href="GHC.Tc.Types.Constraint.html#ctEvId"><span class="hs-identifier hs-var">ctEvId</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101609"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101619"><span class="hs-identifier hs-var">co_vars</span></a></span><span>
</span><span id="line-973"></span><span>
</span><span id="line-974"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; TcM Bool
</span><a href="GHC.Tc.Utils.TcMType.html#promoteTyVarSet"><span class="hs-identifier hs-var">promoteTyVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts -&gt; VarSet
</span><a href="GHC.Tc.Types.Constraint.html#tyCoVarsOfCts"><span class="hs-identifier hs-var">tyCoVarsOfCts</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101613"><span class="hs-identifier hs-var">outer_simple</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-975"></span><span>
</span><span id="line-976"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101605"><span class="annot"><span class="annottext">inner_wanted :: WantedConstraints
</span><a href="#local-6989586621681101605"><span class="hs-identifier hs-var hs-var">inner_wanted</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101616"><span class="hs-identifier hs-var">wanteds</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101612"><span class="hs-identifier hs-var">inner_simple</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-977"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101604"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101604"><span class="hs-identifier hs-var">implics</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isEmptyWC"><span class="hs-identifier hs-var">isEmptyWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101605"><span class="hs-identifier hs-var">inner_wanted</span></a></span><span>
</span><span id="line-978"></span><span>                     </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Bag Implication -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Bag Implication)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span>
</span><span id="line-979"></span><span>                     </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681101602"><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101602"><span class="hs-identifier hs-var">implic1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM Implication
</span><a href="GHC.Tc.Utils.TcMType.html#newImplication"><span class="hs-identifier hs-var">newImplication</span></a></span><span>
</span><span id="line-980"></span><span>                             </span><span class="annot"><span class="annottext">Bag Implication -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Bag Implication)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Bag Implication
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Bag Implication))
-&gt; Bag Implication
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Bag Implication)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Implication -&gt; Bag Implication
forall a. a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unitBag"><span class="hs-identifier hs-var">unitBag</span></a></span><span> </span><span class="annot"><span class="annottext">(Implication -&gt; Bag Implication) -&gt; Implication -&gt; Bag Implication
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-981"></span><span>                                      </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101602"><span class="hs-identifier hs-var">implic1</span></a></span><span>  </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_tclvl :: TcLevel
</span><a href="GHC.Tc.Types.Constraint.html#ic_tclvl"><span class="hs-identifier hs-var">ic_tclvl</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101622"><span class="hs-identifier hs-var">rhs_tclvl</span></a></span><span>
</span><span id="line-982"></span><span>                                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_skols :: [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_skols"><span class="hs-identifier hs-var">ic_skols</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101618"><span class="hs-identifier hs-var">qtvs</span></a></span><span>
</span><span id="line-983"></span><span>                                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_given :: [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_given"><span class="hs-identifier hs-var">ic_given</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101617"><span class="hs-identifier hs-var">full_theta_vars</span></a></span><span>
</span><span id="line-984"></span><span>                                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101605"><span class="hs-identifier hs-var">inner_wanted</span></a></span><span>
</span><span id="line-985"></span><span>                                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_binds :: EvBindsVar
</span><a href="GHC.Tc.Types.Constraint.html#ic_binds"><span class="hs-identifier hs-var">ic_binds</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101621"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span>
</span><span id="line-986"></span><span>                                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_no_eqs :: Bool
</span><a href="GHC.Tc.Types.Constraint.html#ic_no_eqs"><span class="hs-identifier hs-var">ic_no_eqs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-987"></span><span>                                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_info :: SkolemInfo
</span><a href="GHC.Tc.Types.Constraint.html#ic_info"><span class="hs-identifier hs-var">ic_info</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681101596"><span class="hs-identifier hs-var">skol_info</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-988"></span><span>
</span><span id="line-989"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#emptyWC"><span class="hs-identifier hs-var">emptyWC</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101613"><span class="hs-identifier hs-var">outer_simple</span></a></span><span>
</span><span id="line-990"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_impl :: Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101604"><span class="hs-identifier hs-var">implics</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">}</span><span>
</span><span id="line-991"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-992"></span><span>    </span><span id="local-6989586621681101595"><span class="annot"><span class="annottext">full_theta :: [Type]
</span><a href="#local-6989586621681101595"><span class="hs-identifier hs-var hs-var">full_theta</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcTyVar -&gt; Type) -&gt; [TcTyVar] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101617"><span class="hs-identifier hs-var">full_theta_vars</span></a></span><span>
</span><span id="line-993"></span><span>    </span><span id="local-6989586621681101596"><span class="annot"><span class="annottext">skol_info :: SkolemInfo
</span><a href="#local-6989586621681101596"><span class="hs-identifier hs-var hs-var">skol_info</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Name, Type)] -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#InferSkol"><span class="hs-identifier hs-var">InferSkol</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681101593"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[TyCoVarBinder] -&gt; [Type] -&gt; Type -&gt; Type
</span><a href="GHC.Tc.Utils.TcType.html#mkSigmaTy"><span class="hs-identifier hs-var">mkSigmaTy</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101595"><span class="hs-identifier hs-var">full_theta</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101591"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-994"></span><span>                           </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101593"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681101593"><span class="hs-identifier hs-var">name</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101591"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101591"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101620"><span class="hs-identifier hs-var">name_taus</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-995"></span><span>                 </span><span class="hs-comment">-- Don't add the quantified variables here, because</span><span>
</span><span id="line-996"></span><span>                 </span><span class="hs-comment">-- they are also bound in ic_skols and we want them</span><span>
</span><span id="line-997"></span><span>                 </span><span class="hs-comment">-- to be tidied uniformly</span><span>
</span><span id="line-998"></span><span>
</span><span id="line-999"></span><span class="hs-comment">--------------------</span><span>
</span><span id="line-1000"></span><span class="annot"><a href="GHC.Tc.Solver.html#ctsPreds"><span class="hs-identifier hs-type">ctsPreds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Cts"><span class="hs-identifier hs-type">Cts</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1001"></span><span id="ctsPreds"><span class="annot"><span class="annottext">ctsPreds :: Cts -&gt; [Type]
</span><a href="GHC.Tc.Solver.html#ctsPreds"><span class="hs-identifier hs-var hs-var">ctsPreds</span></a></span></span><span> </span><span id="local-6989586621681101589"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101589"><span class="hs-identifier hs-var">cts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Type
</span><a href="GHC.Tc.Types.Constraint.html#ctEvPred"><span class="hs-identifier hs-var">ctEvPred</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681101587"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681101586"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101586"><span class="hs-identifier hs-var">ct</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Cts -&gt; [Ct]
forall a. Bag a -&gt; [a]
</span><a href="GHC.Data.Bag.html#bagToList"><span class="hs-identifier hs-var">bagToList</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101589"><span class="hs-identifier hs-var">cts</span></a></span><span>
</span><span id="line-1002"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101587"><span class="annot"><span class="annottext">ev :: CtEvidence
</span><a href="#local-6989586621681101587"><span class="hs-identifier hs-var hs-var">ev</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#ctEvidence"><span class="hs-identifier hs-var">ctEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101586"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1003"></span><span>
</span><span id="line-1004"></span><span class="hs-comment">{- Note [Emitting the residual implication in simplifyInfer]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
   f = e
where f's type is inferred to be something like (a, Proxy k (Int |&gt; co))
and we have an as-yet-unsolved, or perhaps insoluble, constraint
   [W] co :: Type ~ k
We can't form types like (forall co. blah), so we can't generalise over
the coercion variable, and hence we can't generalise over things free in
its kind, in the case 'k'.  But we can still generalise over 'a'.  So
we'll generalise to
   f :: forall a. (a, Proxy k (Int |&gt; co))
Now we do NOT want to form the residual implication constraint
   forall a. [W] co :: Type ~ k
because then co's eventual binding (which will be a value binding if we
use -fdefer-type-errors) won't scope over the entire binding for 'f' (whose
type mentions 'co').  Instead, just as we don't generalise over 'co', we
should not bury its constraint inside the implication.  Instead, we must
put it outside.

That is the reason for the partitionBag in emitResidualConstraints,
which takes the CoVars free in the inferred type, and pulls their
constraints out.  (NB: this set of CoVars should be closed-over-kinds.)

All rather subtle; see #14584.

Note [Add signature contexts as givens]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this (#11016):
  f2 :: (?x :: Int) =&gt; _
  f2 = ?x
or this
  f3 :: a ~ Bool =&gt; (a, _)
  f3 = (True, False)
or theis
  f4 :: (Ord a, _) =&gt; a -&gt; Bool
  f4 x = x==x

We'll use plan InferGen because there are holes in the type.  But:
 * For f2 we want to have the (?x :: Int) constraint floating around
   so that the functional dependencies kick in.  Otherwise the
   occurrence of ?x on the RHS produces constraint (?x :: alpha), and
   we won't unify alpha:=Int.
 * For f3 we want the (a ~ Bool) available to solve the wanted (a ~ Bool)
   in the RHS
 * For f4 we want to use the (Ord a) in the signature to solve the Eq a
   constraint.

Solution: in simplifyInfer, just before simplifying the constraints
gathered from the RHS, add Given constraints for the context of any
type signatures.

************************************************************************
*                                                                      *
                Quantification
*                                                                      *
************************************************************************

Note [Deciding quantification]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If the monomorphism restriction does not apply, then we quantify as follows:

* Step 1. Take the global tyvars, and &quot;grow&quot; them using the equality
  constraints
     E.g.  if x:alpha is in the environment, and alpha ~ [beta] (which can
          happen because alpha is untouchable here) then do not quantify over
          beta, because alpha fixes beta, and beta is effectively free in
          the environment too

  We also account for the monomorphism restriction; if it applies,
  add the free vars of all the constraints.

  Result is mono_tvs; we will not quantify over these.

* Step 2. Default any non-mono tyvars (i.e ones that are definitely
  not going to become further constrained), and re-simplify the
  candidate constraints.

  Motivation for re-simplification (#7857): imagine we have a
  constraint (C (a-&gt;b)), where 'a :: TYPE l1' and 'b :: TYPE l2' are
  not free in the envt, and instance forall (a::*) (b::*). (C a) =&gt; C
  (a -&gt; b) The instance doesn't match while l1,l2 are polymorphic, but
  it will match when we default them to LiftedRep.

  This is all very tiresome.

* Step 3: decide which variables to quantify over, as follows:

  - Take the free vars of the tau-type (zonked_tau_tvs) and &quot;grow&quot;
    them using all the constraints.  These are tau_tvs_plus

  - Use quantifyTyVars to quantify over (tau_tvs_plus - mono_tvs), being
    careful to close over kinds, and to skolemise the quantified tyvars.
    (This actually unifies each quantifies meta-tyvar with a fresh skolem.)

  Result is qtvs.

* Step 4: Filter the constraints using pickQuantifiablePreds and the
  qtvs. We have to zonk the constraints first, so they &quot;see&quot; the
  freshly created skolems.

-}</span><span>
</span><span id="line-1106"></span><span>
</span><span id="line-1107"></span><span class="annot"><a href="GHC.Tc.Solver.html#decideQuantification"><span class="hs-identifier hs-type">decideQuantification</span></a></span><span>
</span><span id="line-1108"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.html#InferMode"><span class="hs-identifier hs-type">InferMode</span></a></span><span>
</span><span id="line-1109"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcLevel"><span class="hs-identifier hs-type">TcLevel</span></a></span><span>
</span><span id="line-1110"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTauType"><span class="hs-identifier hs-type">TcTauType</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>   </span><span class="hs-comment">-- Variables to be generalised</span><span>
</span><span id="line-1111"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.html#TcIdSigInst"><span class="hs-identifier hs-type">TcIdSigInst</span></a></span><span class="hs-special">]</span><span>         </span><span class="hs-comment">-- Partial type signatures (if any)</span><span>
</span><span id="line-1112"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span class="hs-special">]</span><span>            </span><span class="hs-comment">-- Candidate theta; already zonked</span><span>
</span><span id="line-1113"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span>       </span><span class="hs-comment">-- Quantify over these (skolems)</span><span>
</span><span id="line-1114"></span><span>         </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span class="hs-special">]</span><span>      </span><span class="hs-comment">-- and this context (fully zonked)</span><span>
</span><span id="line-1115"></span><span>         </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1116"></span><span class="hs-comment">-- See Note [Deciding quantification]</span><span>
</span><span id="line-1117"></span><span id="decideQuantification"><span class="annot"><span class="annottext">decideQuantification :: InferMode
-&gt; TcLevel
-&gt; [(Name, Type)]
-&gt; [TcIdSigInst]
-&gt; [Type]
-&gt; TcM ([TcTyVar], [Type], VarSet)
</span><a href="GHC.Tc.Solver.html#decideQuantification"><span class="hs-identifier hs-var hs-var">decideQuantification</span></a></span></span><span> </span><span id="local-6989586621681101585"><span class="annot"><span class="annottext">InferMode
</span><a href="#local-6989586621681101585"><span class="hs-identifier hs-var">infer_mode</span></a></span></span><span> </span><span id="local-6989586621681101584"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101584"><span class="hs-identifier hs-var">rhs_tclvl</span></a></span></span><span> </span><span id="local-6989586621681101583"><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101583"><span class="hs-identifier hs-var">name_taus</span></a></span></span><span> </span><span id="local-6989586621681101582"><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101582"><span class="hs-identifier hs-var">psigs</span></a></span></span><span> </span><span id="local-6989586621681101581"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101581"><span class="hs-identifier hs-var">candidates</span></a></span></span><span>
</span><span id="line-1118"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- Step 1: find the mono_tvs</span><span>
</span><span id="line-1119"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101580"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101580"><span class="hs-identifier hs-var">mono_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101579"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101579"><span class="hs-identifier hs-var">candidates</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101578"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101578"><span class="hs-identifier hs-var">co_vars</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">InferMode
-&gt; [(Name, Type)]
-&gt; [TcIdSigInst]
-&gt; [Type]
-&gt; TcM (VarSet, [Type], VarSet)
</span><a href="GHC.Tc.Solver.html#decideMonoTyVars"><span class="hs-identifier hs-var">decideMonoTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">InferMode
</span><a href="#local-6989586621681101585"><span class="hs-identifier hs-var">infer_mode</span></a></span><span>
</span><span id="line-1120"></span><span>                                              </span><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101583"><span class="hs-identifier hs-var">name_taus</span></a></span><span> </span><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101582"><span class="hs-identifier hs-var">psigs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101581"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1121"></span><span>
</span><span id="line-1122"></span><span>       </span><span class="hs-comment">-- Step 2: default any non-mono tyvars, and re-simplify</span><span>
</span><span id="line-1123"></span><span>       </span><span class="hs-comment">-- This step may do some unification, but result candidates is zonked</span><span>
</span><span id="line-1124"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101576"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101576"><span class="hs-identifier hs-var">candidates</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; VarSet -&gt; [Type] -&gt; TcM [Type]
</span><a href="GHC.Tc.Solver.html#defaultTyVarsAndSimplify"><span class="hs-identifier hs-var">defaultTyVarsAndSimplify</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101584"><span class="hs-identifier hs-var">rhs_tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101580"><span class="hs-identifier hs-var">mono_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101579"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1125"></span><span>
</span><span id="line-1126"></span><span>       </span><span class="hs-comment">-- Step 3: decide which kind/type variables to quantify over</span><span>
</span><span id="line-1127"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101574"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101574"><span class="hs-identifier hs-var">qtvs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Name, Type)] -&gt; [TcIdSigInst] -&gt; [Type] -&gt; TcM [TcTyVar]
</span><a href="GHC.Tc.Solver.html#decideQuantifiedTyVars"><span class="hs-identifier hs-var">decideQuantifiedTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101583"><span class="hs-identifier hs-var">name_taus</span></a></span><span> </span><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101582"><span class="hs-identifier hs-var">psigs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101576"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1128"></span><span>
</span><span id="line-1129"></span><span>       </span><span class="hs-comment">-- Step 4: choose which of the remaining candidate</span><span>
</span><span id="line-1130"></span><span>       </span><span class="hs-comment">--         predicates to actually quantify over</span><span>
</span><span id="line-1131"></span><span>       </span><span class="hs-comment">-- NB: decideQuantifiedTyVars turned some meta tyvars</span><span>
</span><span id="line-1132"></span><span>       </span><span class="hs-comment">-- into quantified skolems, so we have to zonk again</span><span>
</span><span id="line-1133"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101572"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101572"><span class="hs-identifier hs-var">candidates</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; TcM [Type]
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTypes"><span class="hs-identifier hs-var">TcM.zonkTcTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101576"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1134"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101570"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101570"><span class="hs-identifier hs-var">psig_theta</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; TcM [Type]
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTypes"><span class="hs-identifier hs-var">TcM.zonkTcTypes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(TcIdSigInst -&gt; [Type]) -&gt; [TcIdSigInst] -&gt; [Type]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="annot"><span class="annottext">TcIdSigInst -&gt; [Type]
</span><a href="GHC.Tc.Types.html#sig_inst_theta"><span class="hs-identifier hs-var hs-var">sig_inst_theta</span></a></span><span> </span><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101582"><span class="hs-identifier hs-var">psigs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1135"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101569"><span class="annot"><span class="annottext">quantifiable_candidates :: [Type]
</span><a href="#local-6989586621681101569"><span class="hs-identifier hs-var hs-var">quantifiable_candidates</span></a></span></span><span>
</span><span id="line-1136"></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; [Type] -&gt; [Type]
</span><a href="GHC.Tc.Utils.TcType.html#pickQuantifiablePreds"><span class="hs-identifier hs-var">pickQuantifiablePreds</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcTyVar] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mkVarSet"><span class="hs-identifier hs-var">mkVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101574"><span class="hs-identifier hs-var">qtvs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101572"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1137"></span><span>             </span><span class="hs-comment">-- NB: do /not/ run pickQuantifiablePreds over psig_theta,</span><span>
</span><span id="line-1138"></span><span>             </span><span class="hs-comment">-- because we always want to quantify over psig_theta, and not</span><span>
</span><span id="line-1139"></span><span>             </span><span class="hs-comment">-- drop any of them; e.g. CallStack constraints.  c.f #14658</span><span>
</span><span id="line-1140"></span><span>
</span><span id="line-1141"></span><span>             </span><span id="local-6989586621681101566"><span class="annot"><span class="annottext">theta :: [Type]
</span><a href="#local-6989586621681101566"><span class="hs-identifier hs-var hs-var">theta</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; [Type] -&gt; [Type]
forall a. (a -&gt; Type) -&gt; [a] -&gt; [a]
</span><a href="GHC.Tc.Utils.TcType.html#mkMinimalBySCs"><span class="hs-identifier hs-var">mkMinimalBySCs</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">([Type] -&gt; [Type]) -&gt; [Type] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>  </span><span class="hs-comment">-- See Note [Minimize by Superclasses]</span><span>
</span><span id="line-1142"></span><span>                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101570"><span class="hs-identifier hs-var">psig_theta</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; [Type]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101569"><span class="hs-identifier hs-var">quantifiable_candidates</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1143"></span><span>
</span><span id="line-1144"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;decideQuantification&quot;</span></span><span>
</span><span id="line-1145"></span><span>           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;infer_mode:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">InferMode -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">InferMode
</span><a href="#local-6989586621681101585"><span class="hs-identifier hs-var">infer_mode</span></a></span><span>
</span><span id="line-1146"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;candidates:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101572"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1147"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;psig_theta:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101570"><span class="hs-identifier hs-var">psig_theta</span></a></span><span>
</span><span id="line-1148"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;mono_tvs:&quot;</span></span><span>   </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101580"><span class="hs-identifier hs-var">mono_tvs</span></a></span><span>
</span><span id="line-1149"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;co_vars:&quot;</span></span><span>    </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101578"><span class="hs-identifier hs-var">co_vars</span></a></span><span>
</span><span id="line-1150"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;qtvs:&quot;</span></span><span>       </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101574"><span class="hs-identifier hs-var">qtvs</span></a></span><span>
</span><span id="line-1151"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;theta:&quot;</span></span><span>      </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101566"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1152"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([TcTyVar], [Type], VarSet) -&gt; TcM ([TcTyVar], [Type], VarSet)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101574"><span class="hs-identifier hs-var">qtvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101566"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101578"><span class="hs-identifier hs-var">co_vars</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1153"></span><span>
</span><span id="line-1154"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-1155"></span><span class="annot"><a href="GHC.Tc.Solver.html#decideMonoTyVars"><span class="hs-identifier hs-type">decideMonoTyVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.html#InferMode"><span class="hs-identifier hs-type">InferMode</span></a></span><span>
</span><span id="line-1156"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-1157"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.html#TcIdSigInst"><span class="hs-identifier hs-type">TcIdSigInst</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1158"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1159"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyCoVarSet"><span class="hs-identifier hs-type">TcTyCoVarSet</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#CoVarSet"><span class="hs-identifier hs-type">CoVarSet</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1160"></span><span class="hs-comment">-- Decide which tyvars and covars cannot be generalised:</span><span>
</span><span id="line-1161"></span><span class="hs-comment">--   (a) Free in the environment</span><span>
</span><span id="line-1162"></span><span class="hs-comment">--   (b) Mentioned in a constraint we can't generalise</span><span>
</span><span id="line-1163"></span><span class="hs-comment">--   (c) Connected by an equality to (a) or (b)</span><span>
</span><span id="line-1164"></span><span class="hs-comment">-- Also return CoVars that appear free in the final quantified types</span><span>
</span><span id="line-1165"></span><span class="hs-comment">--   we can't quantify over these, and we must make sure they are in scope</span><span>
</span><span id="line-1166"></span><span id="decideMonoTyVars"><span class="annot"><span class="annottext">decideMonoTyVars :: InferMode
-&gt; [(Name, Type)]
-&gt; [TcIdSigInst]
-&gt; [Type]
-&gt; TcM (VarSet, [Type], VarSet)
</span><a href="GHC.Tc.Solver.html#decideMonoTyVars"><span class="hs-identifier hs-var hs-var">decideMonoTyVars</span></a></span></span><span> </span><span id="local-6989586621681101561"><span class="annot"><span class="annottext">InferMode
</span><a href="#local-6989586621681101561"><span class="hs-identifier hs-var">infer_mode</span></a></span></span><span> </span><span id="local-6989586621681101560"><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101560"><span class="hs-identifier hs-var">name_taus</span></a></span></span><span> </span><span id="local-6989586621681101559"><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101559"><span class="hs-identifier hs-var">psigs</span></a></span></span><span> </span><span id="local-6989586621681101558"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101558"><span class="hs-identifier hs-var">candidates</span></a></span></span><span>
</span><span id="line-1167"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101557"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101557"><span class="hs-identifier hs-var">no_quant</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101556"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101556"><span class="hs-identifier hs-var">maybe_quant</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">InferMode -&gt; [Type] -&gt; TcM ([Type], [Type])
</span><a href="#local-6989586621681101555"><span class="hs-identifier hs-var">pick</span></a></span><span> </span><span class="annot"><span class="annottext">InferMode
</span><a href="#local-6989586621681101561"><span class="hs-identifier hs-var">infer_mode</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101558"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1168"></span><span>
</span><span id="line-1169"></span><span>       </span><span class="hs-comment">-- If possible, we quantify over partial-sig qtvs, so they are</span><span>
</span><span id="line-1170"></span><span>       </span><span class="hs-comment">-- not mono. Need to zonk them because they are meta-tyvar TyVarTvs</span><span>
</span><span id="line-1171"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101554"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101554"><span class="hs-identifier hs-var">psig_qtvs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TcTyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcTyVar)
-&gt; [TcTyVar] -&gt; TcM [TcTyVar]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt;
TcTyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcTyVar
TcTyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcTyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVarToTyVar"><span class="hs-identifier hs-var">zonkTcTyVarToTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">([TcTyVar] -&gt; TcM [TcTyVar]) -&gt; [TcTyVar] -&gt; TcM [TcTyVar]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[InvisTVBinder] -&gt; [TcTyVar]
forall tv argf. [VarBndr tv argf] -&gt; [tv]
</span><a href="GHC.Types.Var.html#binderVars"><span class="hs-identifier hs-var">binderVars</span></a></span><span> </span><span class="annot"><span class="annottext">([InvisTVBinder] -&gt; [TcTyVar]) -&gt; [InvisTVBinder] -&gt; [TcTyVar]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1172"></span><span>                      </span><span class="annot"><span class="annottext">(TcIdSigInst -&gt; [InvisTVBinder])
-&gt; [TcIdSigInst] -&gt; [InvisTVBinder]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((Name, InvisTVBinder) -&gt; InvisTVBinder)
-&gt; [(Name, InvisTVBinder)] -&gt; [InvisTVBinder]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Name, InvisTVBinder) -&gt; InvisTVBinder
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">([(Name, InvisTVBinder)] -&gt; [InvisTVBinder])
-&gt; (TcIdSigInst -&gt; [(Name, InvisTVBinder)])
-&gt; TcIdSigInst
-&gt; [InvisTVBinder]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">TcIdSigInst -&gt; [(Name, InvisTVBinder)]
</span><a href="GHC.Tc.Types.html#sig_inst_skols"><span class="hs-identifier hs-var hs-var">sig_inst_skols</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101559"><span class="hs-identifier hs-var">psigs</span></a></span><span>
</span><span id="line-1173"></span><span>
</span><span id="line-1174"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101550"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101550"><span class="hs-identifier hs-var">psig_theta</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; TcM Type) -&gt; [Type] -&gt; TcM [Type]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; TcM Type
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">TcM.zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">([Type] -&gt; TcM [Type]) -&gt; [Type] -&gt; TcM [Type]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1175"></span><span>                       </span><span class="annot"><span class="annottext">(TcIdSigInst -&gt; [Type]) -&gt; [TcIdSigInst] -&gt; [Type]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="annot"><span class="annottext">TcIdSigInst -&gt; [Type]
</span><a href="GHC.Tc.Types.html#sig_inst_theta"><span class="hs-identifier hs-var hs-var">sig_inst_theta</span></a></span><span> </span><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101559"><span class="hs-identifier hs-var">psigs</span></a></span><span>
</span><span id="line-1176"></span><span>
</span><span id="line-1177"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101548"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101548"><span class="hs-identifier hs-var">taus</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">((Name, Type) -&gt; TcM Type) -&gt; [(Name, Type)] -&gt; TcM [Type]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; TcM Type
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">TcM.zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; TcM Type)
-&gt; ((Name, Type) -&gt; Type) -&gt; (Name, Type) -&gt; TcM Type
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Name, Type) -&gt; Type
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101560"><span class="hs-identifier hs-var">name_taus</span></a></span><span>
</span><span id="line-1178"></span><span>
</span><span id="line-1179"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101547"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101547"><span class="hs-identifier hs-var">tc_lvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcLevel
</span><a href="GHC.Tc.Utils.Monad.html#getTcLevel"><span class="hs-identifier hs-var">TcM.getTcLevel</span></a></span><span>
</span><span id="line-1180"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101546"><span class="annot"><span class="annottext">psig_tys :: [Type]
</span><a href="#local-6989586621681101546"><span class="hs-identifier hs-var hs-var">psig_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; [Type]
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTys"><span class="hs-identifier hs-var">mkTyVarTys</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101554"><span class="hs-identifier hs-var">psig_qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; [Type]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101550"><span class="hs-identifier hs-var">psig_theta</span></a></span><span>
</span><span id="line-1181"></span><span>
</span><span id="line-1182"></span><span>             </span><span id="local-6989586621681101544"><span class="annot"><span class="annottext">co_vars :: VarSet
</span><a href="#local-6989586621681101544"><span class="hs-identifier hs-var hs-var">co_vars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#coVarsOfTypes"><span class="hs-identifier hs-var">coVarsOfTypes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101546"><span class="hs-identifier hs-var">psig_tys</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; [Type]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101548"><span class="hs-identifier hs-var">taus</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1183"></span><span>             </span><span id="local-6989586621681101542"><span class="annot"><span class="annottext">co_var_tvs :: VarSet
</span><a href="#local-6989586621681101542"><span class="hs-identifier hs-var hs-var">co_var_tvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#closeOverKinds"><span class="hs-identifier hs-var">closeOverKinds</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101544"><span class="hs-identifier hs-var">co_vars</span></a></span><span>
</span><span id="line-1184"></span><span>               </span><span class="hs-comment">-- The co_var_tvs are tvs mentioned in the types of covars or</span><span>
</span><span id="line-1185"></span><span>               </span><span class="hs-comment">-- coercion holes. We can't quantify over these covars, so we</span><span>
</span><span id="line-1186"></span><span>               </span><span class="hs-comment">-- must include the variable in their types in the mono_tvs.</span><span>
</span><span id="line-1187"></span><span>               </span><span class="hs-comment">-- E.g.  If we can't quantify over co :: k~Type, then we can't</span><span>
</span><span id="line-1188"></span><span>               </span><span class="hs-comment">--       quantify over k either!  Hence closeOverKinds</span><span>
</span><span id="line-1189"></span><span>
</span><span id="line-1190"></span><span>             </span><span id="local-6989586621681101540"><span class="annot"><span class="annottext">mono_tvs0 :: VarSet
</span><a href="#local-6989586621681101540"><span class="hs-identifier hs-var hs-var">mono_tvs0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcTyVar -&gt; Bool) -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#filterVarSet"><span class="hs-identifier hs-var">filterVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; (TcTyVar -&gt; Bool) -&gt; TcTyVar -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcMType.html#isQuantifiableTv"><span class="hs-identifier hs-var">isQuantifiableTv</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101547"><span class="hs-identifier hs-var">tc_lvl</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; VarSet) -&gt; VarSet -&gt; VarSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1191"></span><span>                         </span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101558"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1192"></span><span>               </span><span class="hs-comment">-- We need to grab all the non-quantifiable tyvars in the</span><span>
</span><span id="line-1193"></span><span>               </span><span class="hs-comment">-- candidates so that we can grow this set to find other</span><span>
</span><span id="line-1194"></span><span>               </span><span class="hs-comment">-- non-quantifiable tyvars. This can happen with something</span><span>
</span><span id="line-1195"></span><span>               </span><span class="hs-comment">-- like</span><span>
</span><span id="line-1196"></span><span>               </span><span class="hs-comment">--    f x y = ...</span><span>
</span><span id="line-1197"></span><span>               </span><span class="hs-comment">--      where z = x 3</span><span>
</span><span id="line-1198"></span><span>               </span><span class="hs-comment">-- The body of z tries to unify the type of x (call it alpha[1])</span><span>
</span><span id="line-1199"></span><span>               </span><span class="hs-comment">-- with (beta[2] -&gt; gamma[2]). This unification fails because</span><span>
</span><span id="line-1200"></span><span>               </span><span class="hs-comment">-- alpha is untouchable. But we need to know not to quantify over</span><span>
</span><span id="line-1201"></span><span>               </span><span class="hs-comment">-- beta or gamma, because they are in the equality constraint with</span><span>
</span><span id="line-1202"></span><span>               </span><span class="hs-comment">-- alpha. Actual test case: typecheck/should_compile/tc213</span><span>
</span><span id="line-1203"></span><span>
</span><span id="line-1204"></span><span>             </span><span id="local-6989586621681101536"><span class="annot"><span class="annottext">mono_tvs1 :: VarSet
</span><a href="#local-6989586621681101536"><span class="hs-identifier hs-var hs-var">mono_tvs1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101540"><span class="hs-identifier hs-var">mono_tvs0</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101542"><span class="hs-identifier hs-var">co_var_tvs</span></a></span><span>
</span><span id="line-1205"></span><span>
</span><span id="line-1206"></span><span>             </span><span id="local-6989586621681101534"><span class="annot"><span class="annottext">eq_constraints :: [Type]
</span><a href="#local-6989586621681101534"><span class="hs-identifier hs-var hs-var">eq_constraints</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Bool) -&gt; [Type] -&gt; [Type]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Predicate.html#isEqPrimPred"><span class="hs-identifier hs-var">isEqPrimPred</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101558"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1207"></span><span>             </span><span id="local-6989586621681101532"><span class="annot"><span class="annottext">mono_tvs2 :: VarSet
</span><a href="#local-6989586621681101532"><span class="hs-identifier hs-var hs-var">mono_tvs2</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Tc.Solver.html#growThetaTyVars"><span class="hs-identifier hs-var">growThetaTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101534"><span class="hs-identifier hs-var">eq_constraints</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101536"><span class="hs-identifier hs-var">mono_tvs1</span></a></span><span>
</span><span id="line-1208"></span><span>
</span><span id="line-1209"></span><span>             </span><span id="local-6989586621681101531"><span class="annot"><span class="annottext">constrained_tvs :: VarSet
</span><a href="#local-6989586621681101531"><span class="hs-identifier hs-var hs-var">constrained_tvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcTyVar -&gt; Bool) -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#filterVarSet"><span class="hs-identifier hs-var">filterVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcLevel -&gt; TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcMType.html#isQuantifiableTv"><span class="hs-identifier hs-var">isQuantifiableTv</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101547"><span class="hs-identifier hs-var">tc_lvl</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; VarSet) -&gt; VarSet -&gt; VarSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1210"></span><span>                               </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Tc.Solver.html#growThetaTyVars"><span class="hs-identifier hs-var">growThetaTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101534"><span class="hs-identifier hs-var">eq_constraints</span></a></span><span>
</span><span id="line-1211"></span><span>                                               </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101557"><span class="hs-identifier hs-var">no_quant</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1212"></span><span>                                </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#minusVarSet"><span class="hs-operator hs-var">`minusVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101532"><span class="hs-identifier hs-var">mono_tvs2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1213"></span><span>                               </span><span class="annot"><span class="annottext">VarSet -&gt; [TcTyVar] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#delVarSetList"><span class="hs-operator hs-var">`delVarSetList`</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101554"><span class="hs-identifier hs-var">psig_qtvs</span></a></span><span>
</span><span id="line-1214"></span><span>             </span><span class="hs-comment">-- constrained_tvs: the tyvars that we are not going to</span><span>
</span><span id="line-1215"></span><span>             </span><span class="hs-comment">-- quantify solely because of the monomorphism restriction</span><span>
</span><span id="line-1216"></span><span>             </span><span class="hs-comment">--</span><span>
</span><span id="line-1217"></span><span>             </span><span class="hs-comment">-- (`minusVarSet` mono_tvs2`): a type variable is only</span><span>
</span><span id="line-1218"></span><span>             </span><span class="hs-comment">--   &quot;constrained&quot; (so that the MR bites) if it is not</span><span>
</span><span id="line-1219"></span><span>             </span><span class="hs-comment">--   free in the environment (#13785)</span><span>
</span><span id="line-1220"></span><span>             </span><span class="hs-comment">--</span><span>
</span><span id="line-1221"></span><span>             </span><span class="hs-comment">-- (`delVarSetList` psig_qtvs): if the user has explicitly</span><span>
</span><span id="line-1222"></span><span>             </span><span class="hs-comment">--   asked for quantification, then that request &quot;wins&quot;</span><span>
</span><span id="line-1223"></span><span>             </span><span class="hs-comment">--   over the MR.  Note: do /not/ delete psig_qtvs from</span><span>
</span><span id="line-1224"></span><span>             </span><span class="hs-comment">--   mono_tvs1, because mono_tvs1 cannot under any circumstances</span><span>
</span><span id="line-1225"></span><span>             </span><span class="hs-comment">--   be quantified (#14479); see</span><span>
</span><span id="line-1226"></span><span>             </span><span class="hs-comment">--   Note [Quantification and partial signatures], Wrinkle 3, 4</span><span>
</span><span id="line-1227"></span><span>
</span><span id="line-1228"></span><span>             </span><span id="local-6989586621681101528"><span class="annot"><span class="annottext">mono_tvs :: VarSet
</span><a href="#local-6989586621681101528"><span class="hs-identifier hs-var hs-var">mono_tvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101532"><span class="hs-identifier hs-var">mono_tvs2</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101531"><span class="hs-identifier hs-var">constrained_tvs</span></a></span><span>
</span><span id="line-1229"></span><span>
</span><span id="line-1230"></span><span>           </span><span class="hs-comment">-- Warn about the monomorphism restriction</span><span>
</span><span id="line-1231"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101527"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101527"><span class="hs-identifier hs-var">warn_mono</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WarningFlag -&gt; TcM Bool
forall gbl lcl. WarningFlag -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#woptM"><span class="hs-identifier hs-var">woptM</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnMonomorphism"><span class="hs-identifier hs-var">Opt_WarnMonomorphism</span></a></span><span>
</span><span id="line-1232"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcM () -&gt; TcM ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">InferMode
</span><a href="#local-6989586621681101561"><span class="hs-identifier hs-var">infer_mode</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">InferMode
</span><a href="GHC.Tc.Solver.html#ApplyMR"><span class="hs-identifier hs-var">ApplyMR</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101527"><span class="hs-identifier hs-var">warn_mono</span></a></span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">InferMode
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcM () -&gt; TcM ()) -&gt; TcM () -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1233"></span><span>         </span><span class="annot"><span class="annottext">WarnReason -&gt; Bool -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#warnTc"><span class="hs-identifier hs-var">warnTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WarningFlag -&gt; WarnReason
</span><a href="GHC.Driver.Flags.html#Reason"><span class="hs-identifier hs-var">Reason</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnMonomorphism"><span class="hs-identifier hs-var">Opt_WarnMonomorphism</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1234"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101531"><span class="hs-identifier hs-var">constrained_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#intersectsVarSet"><span class="hs-operator hs-var">`intersectsVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101548"><span class="hs-identifier hs-var">taus</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1235"></span><span>                </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681101521"><span class="hs-identifier hs-var">mr_msg</span></a></span><span>
</span><span id="line-1236"></span><span>
</span><span id="line-1237"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;decideMonoTyVars&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcM ()) -&gt; SDoc -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span>
</span><span id="line-1238"></span><span>           </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;mono_tvs0 =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101540"><span class="hs-identifier hs-var">mono_tvs0</span></a></span><span>
</span><span id="line-1239"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;no_quant =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101557"><span class="hs-identifier hs-var">no_quant</span></a></span><span>
</span><span id="line-1240"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;maybe_quant =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101556"><span class="hs-identifier hs-var">maybe_quant</span></a></span><span>
</span><span id="line-1241"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;eq_constraints =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101534"><span class="hs-identifier hs-var">eq_constraints</span></a></span><span>
</span><span id="line-1242"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;mono_tvs =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101528"><span class="hs-identifier hs-var">mono_tvs</span></a></span><span>
</span><span id="line-1243"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;co_vars =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101544"><span class="hs-identifier hs-var">co_vars</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1244"></span><span>
</span><span id="line-1245"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(VarSet, [Type], VarSet) -&gt; TcM (VarSet, [Type], VarSet)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101528"><span class="hs-identifier hs-var">mono_tvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101556"><span class="hs-identifier hs-var">maybe_quant</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101544"><span class="hs-identifier hs-var">co_vars</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1246"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1247"></span><span>    </span><span class="annot"><a href="#local-6989586621681101555"><span class="hs-identifier hs-type">pick</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.html#InferMode"><span class="hs-identifier hs-type">InferMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1248"></span><span>    </span><span class="hs-comment">-- Split the candidates into ones we definitely</span><span>
</span><span id="line-1249"></span><span>    </span><span class="hs-comment">-- won't quantify, and ones that we might</span><span>
</span><span id="line-1250"></span><span>    </span><span id="local-6989586621681101555"><span class="annot"><span class="annottext">pick :: InferMode -&gt; [Type] -&gt; TcM ([Type], [Type])
</span><a href="#local-6989586621681101555"><span class="hs-identifier hs-var hs-var">pick</span></a></span></span><span> </span><span class="annot"><span class="annottext">InferMode
</span><a href="GHC.Tc.Solver.html#NoRestrictions"><span class="hs-identifier hs-var">NoRestrictions</span></a></span><span>  </span><span id="local-6989586621681101520"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101520"><span class="hs-identifier hs-var">cand</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Type], [Type]) -&gt; TcM ([Type], [Type])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101520"><span class="hs-identifier hs-var">cand</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1251"></span><span>    </span><span class="annot"><a href="#local-6989586621681101555"><span class="hs-identifier hs-var">pick</span></a></span><span> </span><span class="annot"><span class="annottext">InferMode
</span><a href="GHC.Tc.Solver.html#ApplyMR"><span class="hs-identifier hs-var">ApplyMR</span></a></span><span>         </span><span id="local-6989586621681101519"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101519"><span class="hs-identifier hs-var">cand</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Type], [Type]) -&gt; TcM ([Type], [Type])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101519"><span class="hs-identifier hs-var">cand</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1252"></span><span>    </span><span class="annot"><a href="#local-6989586621681101555"><span class="hs-identifier hs-var">pick</span></a></span><span> </span><span class="annot"><span class="annottext">InferMode
</span><a href="GHC.Tc.Solver.html#EagerDefaulting"><span class="hs-identifier hs-var">EagerDefaulting</span></a></span><span> </span><span id="local-6989586621681101518"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101518"><span class="hs-identifier hs-var">cand</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101517"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101517"><span class="hs-identifier hs-var">os</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcM Bool
forall gbl lcl. Extension -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#xoptM"><span class="hs-identifier hs-var">xoptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#OverloadedStrings"><span class="hs-identifier hs-var">LangExt.OverloadedStrings</span></a></span><span>
</span><span id="line-1253"></span><span>                                   </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([Type], [Type]) -&gt; TcM ([Type], [Type])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Type -&gt; Bool) -&gt; [Type] -&gt; ([Type], [Type])
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/Data.OldList.html#partition"><span class="hs-identifier hs-var">partition</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Type -&gt; Bool
</span><a href="#local-6989586621681101515"><span class="hs-identifier hs-var">is_int_ct</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101517"><span class="hs-identifier hs-var">os</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101518"><span class="hs-identifier hs-var">cand</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1254"></span><span>
</span><span id="line-1255"></span><span>    </span><span class="hs-comment">-- For EagerDefaulting, do not quantify over</span><span>
</span><span id="line-1256"></span><span>    </span><span class="hs-comment">-- over any interactive class constraint</span><span>
</span><span id="line-1257"></span><span>    </span><span id="local-6989586621681101515"><span class="annot"><span class="annottext">is_int_ct :: Bool -&gt; Type -&gt; Bool
</span><a href="#local-6989586621681101515"><span class="hs-identifier hs-var hs-var">is_int_ct</span></a></span></span><span> </span><span id="local-6989586621681101514"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101514"><span class="hs-identifier hs-var">ovl_strings</span></a></span></span><span> </span><span id="local-6989586621681101513"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101513"><span class="hs-identifier hs-var">pred</span></a></span></span><span>
</span><span id="line-1258"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101512"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101512"><span class="hs-identifier hs-var">cls</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Class, [Type])
</span><a href="GHC.Core.Predicate.html#getClassPredTys_maybe"><span class="hs-identifier hs-var">getClassPredTys_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101513"><span class="hs-identifier hs-var">pred</span></a></span><span>
</span><span id="line-1259"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Class -&gt; Bool
</span><a href="GHC.Tc.Solver.html#isInteractiveClass"><span class="hs-identifier hs-var">isInteractiveClass</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101514"><span class="hs-identifier hs-var">ovl_strings</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101512"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-1260"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1261"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1262"></span><span>
</span><span id="line-1263"></span><span>    </span><span id="local-6989586621681101508"><span class="annot"><span class="annottext">pp_bndrs :: SDoc
</span><a href="#local-6989586621681101508"><span class="hs-identifier hs-var hs-var">pp_bndrs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Name, Type) -&gt; SDoc) -&gt; [(Name, Type)] -&gt; SDoc
forall a. (a -&gt; SDoc) -&gt; [a] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#pprWithCommas"><span class="hs-identifier hs-var">pprWithCommas</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; ((Name, Type) -&gt; SDoc) -&gt; (Name, Type) -&gt; SDoc
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">(Name -&gt; SDoc) -&gt; ((Name, Type) -&gt; Name) -&gt; (Name, Type) -&gt; SDoc
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Name, Type) -&gt; Name
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101560"><span class="hs-identifier hs-var">name_taus</span></a></span><span>
</span><span id="line-1264"></span><span>    </span><span id="local-6989586621681101521"><span class="annot"><span class="annottext">mr_msg :: SDoc
</span><a href="#local-6989586621681101521"><span class="hs-identifier hs-var hs-var">mr_msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1265"></span><span>         </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;The Monomorphism Restriction applies to the binding&quot;</span></span><span>
</span><span id="line-1266"></span><span>                     </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, Type)] -&gt; SDoc
forall a. [a] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#plural"><span class="hs-identifier hs-var">plural</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101560"><span class="hs-identifier hs-var">name_taus</span></a></span><span>
</span><span id="line-1267"></span><span>                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;for&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681101508"><span class="hs-identifier hs-var">pp_bndrs</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1268"></span><span>            </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hsep"><span class="hs-identifier hs-var">hsep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Consider giving&quot;</span></span><span>
</span><span id="line-1269"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">[(Name, Type)] -&gt; Bool
forall a. [a] -&gt; Bool
</span><a href="GHC.Utils.Misc.html#isSingleton"><span class="hs-identifier hs-var">isSingleton</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101560"><span class="hs-identifier hs-var">name_taus</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;it&quot;</span></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;them&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-1270"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;a type signature&quot;</span></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1271"></span><span>
</span><span id="line-1272"></span><span class="hs-comment">-------------------</span><span>
</span><span id="line-1273"></span><span class="annot"><a href="GHC.Tc.Solver.html#defaultTyVarsAndSimplify"><span class="hs-identifier hs-type">defaultTyVarsAndSimplify</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcLevel"><span class="hs-identifier hs-type">TcLevel</span></a></span><span>
</span><span id="line-1274"></span><span>                         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyCoVarSet"><span class="hs-identifier hs-type">TyCoVarSet</span></a></span><span>
</span><span id="line-1275"></span><span>                         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span class="hs-special">]</span><span>          </span><span class="hs-comment">-- Assumed zonked</span><span>
</span><span id="line-1276"></span><span>                         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span class="hs-special">]</span><span>      </span><span class="hs-comment">-- Guaranteed zonked</span><span>
</span><span id="line-1277"></span><span class="hs-comment">-- Default any tyvar free in the constraints,</span><span>
</span><span id="line-1278"></span><span class="hs-comment">-- and re-simplify in case the defaulting allows further simplification</span><span>
</span><span id="line-1279"></span><span id="defaultTyVarsAndSimplify"><span class="annot"><span class="annottext">defaultTyVarsAndSimplify :: TcLevel -&gt; VarSet -&gt; [Type] -&gt; TcM [Type]
</span><a href="GHC.Tc.Solver.html#defaultTyVarsAndSimplify"><span class="hs-identifier hs-var hs-var">defaultTyVarsAndSimplify</span></a></span></span><span> </span><span id="local-6989586621681101498"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101498"><span class="hs-identifier hs-var">rhs_tclvl</span></a></span></span><span> </span><span id="local-6989586621681101497"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101497"><span class="hs-identifier hs-var">mono_tvs</span></a></span></span><span> </span><span id="local-6989586621681101496"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101496"><span class="hs-identifier hs-var">candidates</span></a></span></span><span>
</span><span id="line-1280"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span>  </span><span class="hs-comment">-- Promote any tyvars that we cannot generalise</span><span>
</span><span id="line-1281"></span><span>          </span><span class="hs-comment">-- See Note [Promote momomorphic tyvars]</span><span>
</span><span id="line-1282"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;decideMonoTyVars: promotion:&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101497"><span class="hs-identifier hs-var">mono_tvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1283"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101495"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101495"><span class="hs-identifier hs-var">any_promoted</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; TcM Bool
</span><a href="GHC.Tc.Utils.TcMType.html#promoteTyVarSet"><span class="hs-identifier hs-var">promoteTyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101497"><span class="hs-identifier hs-var">mono_tvs</span></a></span><span>
</span><span id="line-1284"></span><span>
</span><span id="line-1285"></span><span>       </span><span class="hs-comment">-- Default any kind/levity vars</span><span>
</span><span id="line-1286"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#DV"><span class="hs-identifier hs-type">DV</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">dv_kvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var">dv_kvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101492"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681101492"><span class="hs-identifier hs-var">cand_kvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_tvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var">dv_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101490"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681101490"><span class="hs-identifier hs-var">cand_tvs</span></a></span></span><span class="hs-special">}</span><span>
</span><span id="line-1287"></span><span>                </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfTypes"><span class="hs-identifier hs-var">candidateQTyVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101496"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1288"></span><span>                </span><span class="hs-comment">-- any covars should already be handled by</span><span>
</span><span id="line-1289"></span><span>                </span><span class="hs-comment">-- the logic in decideMonoTyVars, which looks at</span><span>
</span><span id="line-1290"></span><span>                </span><span class="hs-comment">-- the constraints generated</span><span>
</span><span id="line-1291"></span><span>
</span><span id="line-1292"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101489"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101489"><span class="hs-identifier hs-var">poly_kinds</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcM Bool
forall gbl lcl. Extension -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#xoptM"><span class="hs-identifier hs-var">xoptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#PolyKinds"><span class="hs-identifier hs-var">LangExt.PolyKinds</span></a></span><span>
</span><span id="line-1293"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101487"><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621681101487"><span class="hs-identifier hs-var">default_kvs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TcTyVar -&gt; TcM Bool)
-&gt; [TcTyVar] -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Bool]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; TcTyVar -&gt; TcM Bool
</span><a href="#local-6989586621681101486"><span class="hs-identifier hs-var">default_one</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101489"><span class="hs-identifier hs-var">poly_kinds</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span>
</span><span id="line-1294"></span><span>                             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DTyVarSet -&gt; [TcTyVar]
</span><a href="GHC.Types.Var.Set.html#dVarSetElems"><span class="hs-identifier hs-var">dVarSetElems</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681101492"><span class="hs-identifier hs-var">cand_kvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1295"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101484"><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621681101484"><span class="hs-identifier hs-var">default_tvs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TcTyVar -&gt; TcM Bool)
-&gt; [TcTyVar] -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Bool]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; TcTyVar -&gt; TcM Bool
</span><a href="#local-6989586621681101486"><span class="hs-identifier hs-var">default_one</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101489"><span class="hs-identifier hs-var">poly_kinds</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span>
</span><span id="line-1296"></span><span>                             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DTyVarSet -&gt; [TcTyVar]
</span><a href="GHC.Types.Var.Set.html#dVarSetElems"><span class="hs-identifier hs-var">dVarSetElems</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681101490"><span class="hs-identifier hs-var">cand_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; DTyVarSet -&gt; DTyVarSet
</span><a href="GHC.Types.Var.Set.html#minusDVarSet"><span class="hs-operator hs-var">`minusDVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681101492"><span class="hs-identifier hs-var">cand_kvs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1297"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101480"><span class="annot"><span class="annottext">some_default :: Bool
</span><a href="#local-6989586621681101480"><span class="hs-identifier hs-var hs-var">some_default</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Bool] -&gt; Bool
forall (t :: * -&gt; *). Foldable t =&gt; t Bool -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#or"><span class="hs-identifier hs-var">or</span></a></span><span> </span><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621681101487"><span class="hs-identifier hs-var">default_kvs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">[Bool] -&gt; Bool
forall (t :: * -&gt; *). Foldable t =&gt; t Bool -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#or"><span class="hs-identifier hs-var">or</span></a></span><span> </span><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621681101484"><span class="hs-identifier hs-var">default_tvs</span></a></span><span>
</span><span id="line-1298"></span><span>
</span><span id="line-1299"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1300"></span><span>           </span><span class="annot"><span class="annottext">()
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101480"><span class="hs-identifier hs-var">some_default</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; TcM [Type]
</span><a href="#local-6989586621681101479"><span class="hs-identifier hs-var">simplify_cand</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101496"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1301"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101495"><span class="hs-identifier hs-var">any_promoted</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; TcM Type) -&gt; [Type] -&gt; TcM [Type]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; TcM Type
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">TcM.zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101496"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1302"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; TcM [Type]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101496"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1303"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-1304"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1305"></span><span>    </span><span id="local-6989586621681101486"><span class="annot"><span class="annottext">default_one :: Bool -&gt; Bool -&gt; TcTyVar -&gt; TcM Bool
</span><a href="#local-6989586621681101486"><span class="hs-identifier hs-var hs-var">default_one</span></a></span></span><span> </span><span id="local-6989586621681101476"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101476"><span class="hs-identifier hs-var">poly_kinds</span></a></span></span><span> </span><span id="local-6989586621681101475"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101475"><span class="hs-identifier hs-var">is_kind_var</span></a></span></span><span> </span><span id="local-6989586621681101474"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101474"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-1306"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isMetaTyVar"><span class="hs-identifier hs-var">isMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101474"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1307"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcM Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1308"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101474"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101497"><span class="hs-identifier hs-var">mono_tvs</span></a></span><span>
</span><span id="line-1309"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcM Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1310"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1311"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcTyVar -&gt; TcM Bool
</span><a href="GHC.Tc.Utils.TcMType.html#defaultTyVar"><span class="hs-identifier hs-var">defaultTyVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101476"><span class="hs-identifier hs-var">poly_kinds</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101475"><span class="hs-identifier hs-var">is_kind_var</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101474"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-1312"></span><span>
</span><span id="line-1313"></span><span>    </span><span id="local-6989586621681101479"><span class="annot"><span class="annottext">simplify_cand :: [Type] -&gt; TcM [Type]
</span><a href="#local-6989586621681101479"><span class="hs-identifier hs-var hs-var">simplify_cand</span></a></span></span><span> </span><span id="local-6989586621681101465"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101465"><span class="hs-identifier hs-var">candidates</span></a></span></span><span>
</span><span id="line-1314"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101464"><span class="annot"><span class="annottext">[CtEvidence]
</span><a href="#local-6989586621681101464"><span class="hs-identifier hs-var">clone_wanteds</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; [Type] -&gt; TcM [CtEvidence]
</span><a href="GHC.Tc.Utils.TcMType.html#newWanteds"><span class="hs-identifier hs-var">newWanteds</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#DefaultOrigin"><span class="hs-identifier hs-var">DefaultOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101465"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1315"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WC"><span class="hs-identifier hs-type">WC</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: WantedConstraints -&gt; Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101463"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101463"><span class="hs-identifier hs-var">simples</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcLevel
-&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
-&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
forall a. TcLevel -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#setTcLevel"><span class="hs-identifier hs-var">setTcLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101498"><span class="hs-identifier hs-var">rhs_tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">(TcRnIf TcGblEnv TcLclEnv WantedConstraints
 -&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints)
-&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
-&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1316"></span><span>                                           </span><span class="annot"><span class="annottext">[CtEvidence] -&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
</span><a href="GHC.Tc.Solver.html#simplifyWantedsTcM"><span class="hs-identifier hs-var">simplifyWantedsTcM</span></a></span><span> </span><span class="annot"><span class="annottext">[CtEvidence]
</span><a href="#local-6989586621681101464"><span class="hs-identifier hs-var">clone_wanteds</span></a></span><span>
</span><span id="line-1317"></span><span>              </span><span class="hs-comment">-- Discard evidence; simples is fully zonked</span><span>
</span><span id="line-1318"></span><span>
</span><span id="line-1319"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101462"><span class="annot"><span class="annottext">new_candidates :: [Type]
</span><a href="#local-6989586621681101462"><span class="hs-identifier hs-var hs-var">new_candidates</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts -&gt; [Type]
</span><a href="GHC.Tc.Solver.html#ctsPreds"><span class="hs-identifier hs-var">ctsPreds</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101463"><span class="hs-identifier hs-var">simples</span></a></span><span>
</span><span id="line-1320"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Simplified after defaulting&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcM ()) -&gt; SDoc -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1321"></span><span>                      </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Before:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101465"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1322"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;After:&quot;</span></span><span>  </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101462"><span class="hs-identifier hs-var">new_candidates</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1323"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; TcM [Type]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101462"><span class="hs-identifier hs-var">new_candidates</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1324"></span><span>
</span><span id="line-1325"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-1326"></span><span class="annot"><a href="GHC.Tc.Solver.html#decideQuantifiedTyVars"><span class="hs-identifier hs-type">decideQuantifiedTyVars</span></a></span><span>
</span><span id="line-1327"></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>   </span><span class="hs-comment">-- Annotated theta and (name,tau) pairs</span><span>
</span><span id="line-1328"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.html#TcIdSigInst"><span class="hs-identifier hs-type">TcIdSigInst</span></a></span><span class="hs-special">]</span><span>     </span><span class="hs-comment">-- Partial signatures</span><span>
</span><span id="line-1329"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span class="hs-special">]</span><span>        </span><span class="hs-comment">-- Candidates, zonked</span><span>
</span><span id="line-1330"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1331"></span><span class="hs-comment">-- Fix what tyvars we are going to quantify over, and quantify them</span><span>
</span><span id="line-1332"></span><span id="decideQuantifiedTyVars"><span class="annot"><span class="annottext">decideQuantifiedTyVars :: [(Name, Type)] -&gt; [TcIdSigInst] -&gt; [Type] -&gt; TcM [TcTyVar]
</span><a href="GHC.Tc.Solver.html#decideQuantifiedTyVars"><span class="hs-identifier hs-var hs-var">decideQuantifiedTyVars</span></a></span></span><span> </span><span id="local-6989586621681101460"><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101460"><span class="hs-identifier hs-var">name_taus</span></a></span></span><span> </span><span id="local-6989586621681101459"><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101459"><span class="hs-identifier hs-var">psigs</span></a></span></span><span> </span><span id="local-6989586621681101458"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101458"><span class="hs-identifier hs-var">candidates</span></a></span></span><span>
</span><span id="line-1333"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span>     </span><span class="hs-comment">-- Why psig_tys? We try to quantify over everything free in here</span><span>
</span><span id="line-1334"></span><span>             </span><span class="hs-comment">-- See Note [Quantification and partial signatures]</span><span>
</span><span id="line-1335"></span><span>             </span><span class="hs-comment">--     Wrinkles 2 and 3</span><span>
</span><span id="line-1336"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101457"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101457"><span class="hs-identifier hs-var">psig_tv_tys</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TcTyVar -&gt; TcM Type) -&gt; [TcTyVar] -&gt; TcM [Type]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcM Type
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVar"><span class="hs-identifier hs-var">TcM.zonkTcTyVar</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101455"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681101454"><span class="annot"><span class="annottext">TcIdSigInst
</span><a href="#local-6989586621681101454"><span class="hs-identifier hs-var">sig</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101459"><span class="hs-identifier hs-var">psigs</span></a></span><span>
</span><span id="line-1337"></span><span>                                                  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-type">Bndr</span></a></span><span> </span><span id="local-6989586621681101455"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101455"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="annot"><span class="annottext">Specificity
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcIdSigInst -&gt; [(Name, InvisTVBinder)]
</span><a href="GHC.Tc.Types.html#sig_inst_skols"><span class="hs-identifier hs-var hs-var">sig_inst_skols</span></a></span><span> </span><span class="annot"><span class="annottext">TcIdSigInst
</span><a href="#local-6989586621681101454"><span class="hs-identifier hs-var">sig</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1338"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101453"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101453"><span class="hs-identifier hs-var">psig_theta</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; TcM Type) -&gt; [Type] -&gt; TcM [Type]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; TcM Type
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">TcM.zonkTcType</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101452"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681101451"><span class="annot"><span class="annottext">TcIdSigInst
</span><a href="#local-6989586621681101451"><span class="hs-identifier hs-var">sig</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TcIdSigInst]
</span><a href="#local-6989586621681101459"><span class="hs-identifier hs-var">psigs</span></a></span><span>
</span><span id="line-1339"></span><span>                                                  </span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101452"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101452"><span class="hs-identifier hs-var">pred</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcIdSigInst -&gt; [Type]
</span><a href="GHC.Tc.Types.html#sig_inst_theta"><span class="hs-identifier hs-var hs-var">sig_inst_theta</span></a></span><span> </span><span class="annot"><span class="annottext">TcIdSigInst
</span><a href="#local-6989586621681101451"><span class="hs-identifier hs-var">sig</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1340"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101450"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101450"><span class="hs-identifier hs-var">tau_tys</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">((Name, Type) -&gt; TcM Type) -&gt; [(Name, Type)] -&gt; TcM [Type]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; TcM Type
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">TcM.zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; TcM Type)
-&gt; ((Name, Type) -&gt; Type) -&gt; (Name, Type) -&gt; TcM Type
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Name, Type) -&gt; Type
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Name, Type)]
</span><a href="#local-6989586621681101460"><span class="hs-identifier hs-var">name_taus</span></a></span><span>
</span><span id="line-1341"></span><span>
</span><span id="line-1342"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-comment">-- Try to quantify over variables free in these types</span><span>
</span><span id="line-1343"></span><span>             </span><span id="local-6989586621681101449"><span class="annot"><span class="annottext">psig_tys :: [Type]
</span><a href="#local-6989586621681101449"><span class="hs-identifier hs-var hs-var">psig_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101457"><span class="hs-identifier hs-var">psig_tv_tys</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; [Type]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101453"><span class="hs-identifier hs-var">psig_theta</span></a></span><span>
</span><span id="line-1344"></span><span>             </span><span id="local-6989586621681101448"><span class="annot"><span class="annottext">seed_tys :: [Type]
</span><a href="#local-6989586621681101448"><span class="hs-identifier hs-var hs-var">seed_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101449"><span class="hs-identifier hs-var">psig_tys</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; [Type]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101450"><span class="hs-identifier hs-var">tau_tys</span></a></span><span>
</span><span id="line-1345"></span><span>
</span><span id="line-1346"></span><span>             </span><span class="hs-comment">-- Now &quot;grow&quot; those seeds to find ones reachable via 'candidates'</span><span>
</span><span id="line-1347"></span><span>             </span><span id="local-6989586621681101447"><span class="annot"><span class="annottext">grown_tcvs :: VarSet
</span><a href="#local-6989586621681101447"><span class="hs-identifier hs-var hs-var">grown_tcvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Tc.Solver.html#growThetaTyVars"><span class="hs-identifier hs-var">growThetaTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101458"><span class="hs-identifier hs-var">candidates</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101448"><span class="hs-identifier hs-var">seed_tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1348"></span><span>
</span><span id="line-1349"></span><span>       </span><span class="hs-comment">-- Now we have to classify them into kind variables and type variables</span><span>
</span><span id="line-1350"></span><span>       </span><span class="hs-comment">-- (sigh) just for the benefit of -XNoPolyKinds; see quantifyTyVars</span><span>
</span><span id="line-1351"></span><span>       </span><span class="hs-comment">--</span><span>
</span><span id="line-1352"></span><span>       </span><span class="hs-comment">-- Keep the psig_tys first, so that candidateQTyVarsOfTypes produces</span><span>
</span><span id="line-1353"></span><span>       </span><span class="hs-comment">-- them in that order, so that the final qtvs quantifies in the same</span><span>
</span><span id="line-1354"></span><span>       </span><span class="hs-comment">-- order as the partial signatures do (#13524)</span><span>
</span><span id="line-1355"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101446"><span class="annot"><span class="annottext">dv :: CandidatesQTvs
</span><a href="#local-6989586621681101446"><span class="hs-identifier hs-var">dv</span></a></span></span><span class="hs-glyph">@</span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#DV"><span class="hs-identifier hs-type">DV</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">dv_kvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var">dv_kvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101445"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681101445"><span class="hs-identifier hs-var">cand_kvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_tvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var">dv_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101444"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681101444"><span class="hs-identifier hs-var">cand_tvs</span></a></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfTypes"><span class="hs-identifier hs-var">candidateQTyVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">([Type] -&gt; TcM CandidatesQTvs) -&gt; [Type] -&gt; TcM CandidatesQTvs
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1356"></span><span>                                                         </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101449"><span class="hs-identifier hs-var">psig_tys</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; [Type]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101458"><span class="hs-identifier hs-var">candidates</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; [Type]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101450"><span class="hs-identifier hs-var">tau_tys</span></a></span><span>
</span><span id="line-1357"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101443"><span class="annot"><span class="annottext">pick :: DTyVarSet -&gt; DTyVarSet
</span><a href="#local-6989586621681101443"><span class="hs-identifier hs-var hs-var">pick</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DTyVarSet -&gt; VarSet -&gt; DTyVarSet
</span><a href="GHC.Types.Var.Set.html#dVarSetIntersectVarSet"><span class="hs-operator hs-var">`dVarSetIntersectVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101447"><span class="hs-identifier hs-var">grown_tcvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1358"></span><span>             </span><span id="local-6989586621681101441"><span class="annot"><span class="annottext">dvs_plus :: CandidatesQTvs
</span><a href="#local-6989586621681101441"><span class="hs-identifier hs-var hs-var">dvs_plus</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681101446"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dv_kvs :: DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var">dv_kvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; DTyVarSet
</span><a href="#local-6989586621681101443"><span class="hs-identifier hs-var">pick</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681101445"><span class="hs-identifier hs-var">cand_kvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_tvs :: DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var">dv_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; DTyVarSet
</span><a href="#local-6989586621681101443"><span class="hs-identifier hs-var">pick</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681101444"><span class="hs-identifier hs-var">cand_tvs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1359"></span><span>
</span><span id="line-1360"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;decideQuantifiedTyVars&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span>
</span><span id="line-1361"></span><span>           </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;candidates =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101458"><span class="hs-identifier hs-var">candidates</span></a></span><span>
</span><span id="line-1362"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tau_tys =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101450"><span class="hs-identifier hs-var">tau_tys</span></a></span><span>
</span><span id="line-1363"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;seed_tys =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101448"><span class="hs-identifier hs-var">seed_tys</span></a></span><span>
</span><span id="line-1364"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;seed_tcvs =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101448"><span class="hs-identifier hs-var">seed_tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1365"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;grown_tcvs =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101447"><span class="hs-identifier hs-var">grown_tcvs</span></a></span><span>
</span><span id="line-1366"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dvs =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681101441"><span class="hs-identifier hs-var">dvs_plus</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1367"></span><span>
</span><span id="line-1368"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TcM [TcTyVar]
</span><a href="GHC.Tc.Utils.TcMType.html#quantifyTyVars"><span class="hs-identifier hs-var">quantifyTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681101441"><span class="hs-identifier hs-var">dvs_plus</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1369"></span><span>
</span><span id="line-1370"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-1371"></span><span class="annot"><a href="GHC.Tc.Solver.html#growThetaTyVars"><span class="hs-identifier hs-type">growThetaTyVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyCoVarSet"><span class="hs-identifier hs-type">TyCoVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyCoVarSet"><span class="hs-identifier hs-type">TyCoVarSet</span></a></span><span>
</span><span id="line-1372"></span><span class="hs-comment">-- See Note [Growing the tau-tvs using constraints]</span><span>
</span><span id="line-1373"></span><span id="growThetaTyVars"><span class="annot"><span class="annottext">growThetaTyVars :: [Type] -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Tc.Solver.html#growThetaTyVars"><span class="hs-identifier hs-var hs-var">growThetaTyVars</span></a></span></span><span> </span><span id="local-6989586621681101440"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101440"><span class="hs-identifier hs-var">theta</span></a></span></span><span> </span><span id="local-6989586621681101439"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101439"><span class="hs-identifier hs-var">tcvs</span></a></span></span><span>
</span><span id="line-1374"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101440"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101439"><span class="hs-identifier hs-var">tcvs</span></a></span><span>
</span><span id="line-1375"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; VarSet) -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#transCloVarSet"><span class="hs-identifier hs-var">transCloVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet
</span><a href="#local-6989586621681101436"><span class="hs-identifier hs-var">mk_next</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101435"><span class="hs-identifier hs-var">seed_tcvs</span></a></span><span>
</span><span id="line-1376"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1377"></span><span>    </span><span id="local-6989586621681101435"><span class="annot"><span class="annottext">seed_tcvs :: VarSet
</span><a href="#local-6989586621681101435"><span class="hs-identifier hs-var hs-var">seed_tcvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101439"><span class="hs-identifier hs-var">tcvs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101434"><span class="hs-identifier hs-var">ips</span></a></span><span>
</span><span id="line-1378"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681101434"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101434"><span class="hs-identifier hs-var">ips</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101433"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101433"><span class="hs-identifier hs-var">non_ips</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Bool) -&gt; [Type] -&gt; ([Type], [Type])
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/Data.OldList.html#partition"><span class="hs-identifier hs-var">partition</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Predicate.html#isIPLikePred"><span class="hs-identifier hs-var">isIPLikePred</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101440"><span class="hs-identifier hs-var">theta</span></a></span><span>
</span><span id="line-1379"></span><span>                         </span><span class="hs-comment">-- See Note [Inheriting implicit parameters] in GHC.Tc.Utils.TcType</span><span>
</span><span id="line-1380"></span><span>
</span><span id="line-1381"></span><span>    </span><span class="annot"><a href="#local-6989586621681101436"><span class="hs-identifier hs-type">mk_next</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-comment">-- Maps current set to newly-grown ones</span><span>
</span><span id="line-1382"></span><span>    </span><span id="local-6989586621681101436"><span class="annot"><span class="annottext">mk_next :: VarSet -&gt; VarSet
</span><a href="#local-6989586621681101436"><span class="hs-identifier hs-var hs-var">mk_next</span></a></span></span><span> </span><span id="local-6989586621681101431"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101431"><span class="hs-identifier hs-var">so_far</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; VarSet -&gt; VarSet) -&gt; VarSet -&gt; [Type] -&gt; VarSet
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; Type -&gt; VarSet -&gt; VarSet
</span><a href="#local-6989586621681101429"><span class="hs-identifier hs-var">grow_one</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101431"><span class="hs-identifier hs-var">so_far</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101433"><span class="hs-identifier hs-var">non_ips</span></a></span><span>
</span><span id="line-1383"></span><span>    </span><span id="local-6989586621681101429"><span class="annot"><span class="annottext">grow_one :: VarSet -&gt; Type -&gt; VarSet -&gt; VarSet
</span><a href="#local-6989586621681101429"><span class="hs-identifier hs-var hs-var">grow_one</span></a></span></span><span> </span><span id="local-6989586621681101428"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101428"><span class="hs-identifier hs-var">so_far</span></a></span></span><span> </span><span id="local-6989586621681101427"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101427"><span class="hs-identifier hs-var">pred</span></a></span></span><span> </span><span id="local-6989586621681101426"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101426"><span class="hs-identifier hs-var">tcvs</span></a></span></span><span>
</span><span id="line-1384"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101425"><span class="hs-identifier hs-var">pred_tcvs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#intersectsVarSet"><span class="hs-operator hs-var">`intersectsVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101428"><span class="hs-identifier hs-var">so_far</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101426"><span class="hs-identifier hs-var">tcvs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101425"><span class="hs-identifier hs-var">pred_tcvs</span></a></span><span>
</span><span id="line-1385"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101426"><span class="hs-identifier hs-var">tcvs</span></a></span><span>
</span><span id="line-1386"></span><span>       </span><span class="hs-keyword">where</span><span>
</span><span id="line-1387"></span><span>         </span><span id="local-6989586621681101425"><span class="annot"><span class="annottext">pred_tcvs :: VarSet
</span><a href="#local-6989586621681101425"><span class="hs-identifier hs-var hs-var">pred_tcvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101427"><span class="hs-identifier hs-var">pred</span></a></span><span>
</span><span id="line-1388"></span><span>
</span><span id="line-1389"></span><span>
</span><span id="line-1390"></span><span class="hs-comment">{- Note [Promote momomorphic tyvars]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Promote any type variables that are free in the environment.  Eg
   f :: forall qtvs. bound_theta =&gt; zonked_tau
The free vars of f's type become free in the envt, and hence will show
up whenever 'f' is called.  They may currently at rhs_tclvl, but they
had better be unifiable at the outer_tclvl!  Example: envt mentions
alpha[1]
           tau_ty = beta[2] -&gt; beta[2]
           constraints = alpha ~ [beta]
we don't quantify over beta (since it is fixed by envt)
so we must promote it!  The inferred type is just
  f :: beta -&gt; beta

NB: promoteTyVar ignores coercion variables

Note [Quantification and partial signatures]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When choosing type variables to quantify, the basic plan is to
quantify over all type variables that are
 * free in the tau_tvs, and
 * not forced to be monomorphic (mono_tvs),
   for example by being free in the environment.

However, in the case of a partial type signature, be doing inference
*in the presence of a type signature*. For example:
   f :: _ -&gt; a
   f x = ...
or
   g :: (Eq _a) =&gt; _b -&gt; _b
In both cases we use plan InferGen, and hence call simplifyInfer.  But
those 'a' variables are skolems (actually TyVarTvs), and we should be
sure to quantify over them.  This leads to several wrinkles:

* Wrinkle 1.  In the case of a type error
     f :: _ -&gt; Maybe a
     f x = True &amp;&amp; x
  The inferred type of 'f' is f :: Bool -&gt; Bool, but there's a
  left-over error of form (HoleCan (Maybe a ~ Bool)).  The error-reporting
  machine expects to find a binding site for the skolem 'a', so we
  add it to the quantified tyvars.

* Wrinkle 2.  Consider the partial type signature
     f :: (Eq _) =&gt; Int -&gt; Int
     f x = x
  In normal cases that makes sense; e.g.
     g :: Eq _a =&gt; _a -&gt; _a
     g x = x
  where the signature makes the type less general than it could
  be. But for 'f' we must therefore quantify over the user-annotated
  constraints, to get
     f :: forall a. Eq a =&gt; Int -&gt; Int
  (thereby correctly triggering an ambiguity error later).  If we don't
  we'll end up with a strange open type
     f :: Eq alpha =&gt; Int -&gt; Int
  which isn't ambiguous but is still very wrong.

  Bottom line: Try to quantify over any variable free in psig_theta,
  just like the tau-part of the type.

* Wrinkle 3 (#13482). Also consider
    f :: forall a. _ =&gt; Int -&gt; Int
    f x = if (undefined :: a) == undefined then x else 0
  Here we get an (Eq a) constraint, but it's not mentioned in the
  psig_theta nor the type of 'f'.  But we still want to quantify
  over 'a' even if the monomorphism restriction is on.

* Wrinkle 4 (#14479)
    foo :: Num a =&gt; a -&gt; a
    foo xxx = g xxx
      where
        g :: forall b. Num b =&gt; _ -&gt; b
        g y = xxx + y

  In the signature for 'g', we cannot quantify over 'b' because it turns out to
  get unified with 'a', which is free in g's environment.  So we carefully
  refrain from bogusly quantifying, in GHC.Tc.Solver.decideMonoTyVars.  We
  report the error later, in GHC.Tc.Gen.Bind.chooseInferredQuantifiers.

Note [Growing the tau-tvs using constraints]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(growThetaTyVars insts tvs) is the result of extending the set
    of tyvars, tvs, using all conceivable links from pred

E.g. tvs = {a}, preds = {H [a] b, K (b,Int) c, Eq e}
Then growThetaTyVars preds tvs = {a,b,c}

Notice that
   growThetaTyVars is conservative       if v might be fixed by vs
                                         =&gt; v `elem` grow(vs,C)

Note [Quantification with errors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If we find that the RHS of the definition has some absolutely-insoluble
constraints (including especially &quot;variable not in scope&quot;), we

* Abandon all attempts to find a context to quantify over,
  and instead make the function fully-polymorphic in whatever
  type we have found

* Return a flag from simplifyInfer, indicating that we found an
  insoluble constraint.  This flag is used to suppress the ambiguity
  check for the inferred type, which may well be bogus, and which
  tends to obscure the real error.  This fix feels a bit clunky,
  but I failed to come up with anything better.

Reasons:
    - Avoid downstream errors
    - Do not perform an ambiguity test on a bogus type, which might well
      fail spuriously, thereby obfuscating the original insoluble error.
      #14000 is an example

I tried an alternative approach: simply failM, after emitting the
residual implication constraint; the exception will be caught in
GHC.Tc.Gen.Bind.tcPolyBinds, which gives all the binders in the group the type
(forall a. a).  But that didn't work with -fdefer-type-errors, because
the recovery from failM emits no code at all, so there is no function
to run!   But -fdefer-type-errors aspires to produce a runnable program.

NB that we must include *derived* errors in the check for insolubles.
Example:
    (a::*) ~ Int#
We get an insoluble derived error *~#, and we don't want to discard
it before doing the isInsolubleWC test!  (#8262)

Note [Default while Inferring]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Our current plan is that defaulting only happens at simplifyTop and
not simplifyInfer.  This may lead to some insoluble deferred constraints.
Example:

instance D g =&gt; C g Int b

constraint inferred = (forall b. 0 =&gt; C gamma alpha b) /\ Num alpha
type inferred       = gamma -&gt; gamma

Now, if we try to default (alpha := Int) we will be able to refine the implication to
  (forall b. 0 =&gt; C gamma Int b)
which can then be simplified further to
  (forall b. 0 =&gt; D gamma)
Finally, we /can/ approximate this implication with (D gamma) and infer the quantified
type:  forall g. D g =&gt; g -&gt; g

Instead what will currently happen is that we will get a quantified type
(forall g. g -&gt; g) and an implication:
       forall g. 0 =&gt; (forall b. 0 =&gt; C g alpha b) /\ Num alpha

Which, even if the simplifyTop defaults (alpha := Int) we will still be left with an
unsolvable implication:
       forall g. 0 =&gt; (forall b. 0 =&gt; D g)

The concrete example would be:
       h :: C g a s =&gt; g -&gt; a -&gt; ST s a
       f (x::gamma) = (\_ -&gt; x) (runST (h x (undefined::alpha)) + 1)

But it is quite tedious to do defaulting and resolve the implication constraints, and
we have not observed code breaking because of the lack of defaulting in inference, so
we don't do it for now.



Note [Minimize by Superclasses]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we quantify over a constraint, in simplifyInfer we need to
quantify over a constraint that is minimal in some sense: For
instance, if the final wanted constraint is (Eq alpha, Ord alpha),
we'd like to quantify over Ord alpha, because we can just get Eq alpha
from superclass selection from Ord alpha. This minimization is what
mkMinimalBySCs does. Then, simplifyInfer uses the minimal constraint
to check the original wanted.


Note [Avoid unnecessary constraint simplification]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    -------- NB NB NB (Jun 12) -------------
    This note not longer applies; see the notes with #4361.
    But I'm leaving it in here so we remember the issue.)
    ----------------------------------------
When inferring the type of a let-binding, with simplifyInfer,
try to avoid unnecessarily simplifying class constraints.
Doing so aids sharing, but it also helps with delicate
situations like

   instance C t =&gt; C [t] where ..

   f :: C [t] =&gt; ....
   f x = let g y = ...(constraint C [t])...
         in ...
When inferring a type for 'g', we don't want to apply the
instance decl, because then we can't satisfy (C t).  So we
just notice that g isn't quantified over 't' and partition
the constraints before simplifying.

This only half-works, but then let-generalisation only half-works.

*********************************************************************************
*                                                                                 *
*                                 Main Simplifier                                 *
*                                                                                 *
***********************************************************************************

-}</span><span>
</span><span id="line-1592"></span><span>
</span><span id="line-1593"></span><span class="annot"><a href="GHC.Tc.Solver.html#simplifyWantedsTcM"><span class="hs-identifier hs-type">simplifyWantedsTcM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-1594"></span><span class="hs-comment">-- Solve the specified Wanted constraints</span><span>
</span><span id="line-1595"></span><span class="hs-comment">-- Discard the evidence binds</span><span>
</span><span id="line-1596"></span><span class="hs-comment">-- Discards all Derived stuff in result</span><span>
</span><span id="line-1597"></span><span class="hs-comment">-- Postcondition: fully zonked and unflattened constraints</span><span>
</span><span id="line-1598"></span><span id="simplifyWantedsTcM"><span class="annot"><span class="annottext">simplifyWantedsTcM :: [CtEvidence] -&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
</span><a href="GHC.Tc.Solver.html#simplifyWantedsTcM"><span class="hs-identifier hs-var hs-var">simplifyWantedsTcM</span></a></span></span><span> </span><span id="local-6989586621681101423"><span class="annot"><span class="annottext">[CtEvidence]
</span><a href="#local-6989586621681101423"><span class="hs-identifier hs-var">wanted</span></a></span></span><span>
</span><span id="line-1599"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;simplifyWantedsTcM {&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CtEvidence] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[CtEvidence]
</span><a href="#local-6989586621681101423"><span class="hs-identifier hs-var">wanted</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1600"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101422"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101422"><span class="hs-identifier hs-var">result</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">EvBindMap
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS WantedConstraints -&gt; TcM (WantedConstraints, EvBindMap)
forall a. TcS a -&gt; TcM (a, EvBindMap)
</span><a href="GHC.Tc.Solver.Monad.html#runTcS"><span class="hs-identifier hs-var">runTcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#solveWantedsAndDrop"><span class="hs-identifier hs-var">solveWantedsAndDrop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CtEvidence] -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#mkSimpleWC"><span class="hs-identifier hs-var">mkSimpleWC</span></a></span><span> </span><span class="annot"><span class="annottext">[CtEvidence]
</span><a href="#local-6989586621681101423"><span class="hs-identifier hs-var">wanted</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1601"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101421"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101421"><span class="hs-identifier hs-var">result</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
</span><a href="GHC.Tc.Utils.TcMType.html#zonkWC"><span class="hs-identifier hs-var">TcM.zonkWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101422"><span class="hs-identifier hs-var">result</span></a></span><span>
</span><span id="line-1602"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;simplifyWantedsTcM }&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101421"><span class="hs-identifier hs-var">result</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1603"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcRnIf TcGblEnv TcLclEnv WantedConstraints
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101421"><span class="hs-identifier hs-var">result</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1604"></span><span>
</span><span id="line-1605"></span><span class="annot"><a href="GHC.Tc.Solver.html#solveWantedsAndDrop"><span class="hs-identifier hs-type">solveWantedsAndDrop</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-1606"></span><span class="hs-comment">-- Since solveWanteds returns the residual WantedConstraints,</span><span>
</span><span id="line-1607"></span><span class="hs-comment">-- it should always be called within a runTcS or something similar,</span><span>
</span><span id="line-1608"></span><span class="hs-comment">-- Result is not zonked</span><span>
</span><span id="line-1609"></span><span id="solveWantedsAndDrop"><span class="annot"><span class="annottext">solveWantedsAndDrop :: WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#solveWantedsAndDrop"><span class="hs-identifier hs-var hs-var">solveWantedsAndDrop</span></a></span></span><span> </span><span id="local-6989586621681101420"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101420"><span class="hs-identifier hs-var">wanted</span></a></span></span><span>
</span><span id="line-1610"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101419"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101419"><span class="hs-identifier hs-var">wc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#solveWanteds"><span class="hs-identifier hs-var">solveWanteds</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101420"><span class="hs-identifier hs-var">wanted</span></a></span><span>
</span><span id="line-1611"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#dropDerivedWC"><span class="hs-identifier hs-var">dropDerivedWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101419"><span class="hs-identifier hs-var">wc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1612"></span><span>
</span><span id="line-1613"></span><span class="annot"><a href="GHC.Tc.Solver.html#solveWanteds"><span class="hs-identifier hs-type">solveWanteds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-1614"></span><span class="hs-comment">-- so that the inert set doesn't mindlessly propagate.</span><span>
</span><span id="line-1615"></span><span class="hs-comment">-- NB: wc_simples may be wanted /or/ derived now</span><span>
</span><span id="line-1616"></span><span id="solveWanteds"><span class="annot"><span class="annottext">solveWanteds :: WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#solveWanteds"><span class="hs-identifier hs-var hs-var">solveWanteds</span></a></span></span><span> </span><span id="local-6989586621681101418"><span class="annot"><span class="annottext">wc :: WantedConstraints
</span><a href="#local-6989586621681101418"><span class="hs-identifier hs-var">wc</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WC"><span class="hs-identifier hs-type">WC</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: WantedConstraints -&gt; Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101417"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101417"><span class="hs-identifier hs-var">simples</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_impl :: WantedConstraints -&gt; Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101416"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101416"><span class="hs-identifier hs-var">implics</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_holes :: WantedConstraints -&gt; Bag Hole
</span><a href="GHC.Tc.Types.Constraint.html#wc_holes"><span class="hs-identifier hs-var">wc_holes</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101415"><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681101415"><span class="hs-identifier hs-var">holes</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1617"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101414"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101414"><span class="hs-identifier hs-var">cur_lvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS TcLevel
</span><a href="GHC.Tc.Solver.Monad.html#getTcLevel"><span class="hs-identifier hs-var">TcS.getTcLevel</span></a></span><span>
</span><span id="line-1618"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;solveWanteds {&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcS ()) -&gt; SDoc -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1619"></span><span>         </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Level =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101414"><span class="hs-identifier hs-var">cur_lvl</span></a></span><span>
</span><span id="line-1620"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101418"><span class="hs-identifier hs-var">wc</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1621"></span><span>
</span><span id="line-1622"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101412"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101412"><span class="hs-identifier hs-var">wc1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Cts -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.Interact.html#solveSimpleWanteds"><span class="hs-identifier hs-var">solveSimpleWanteds</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101417"><span class="hs-identifier hs-var">simples</span></a></span><span>
</span><span id="line-1623"></span><span>                </span><span class="hs-comment">-- Any insoluble constraints are in 'simples' and so get rewritten</span><span>
</span><span id="line-1624"></span><span>                </span><span class="hs-comment">-- See Note [Rewrite insolubles] in GHC.Tc.Solver.Monad</span><span>
</span><span id="line-1625"></span><span>
</span><span id="line-1626"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101410"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101410"><span class="hs-identifier hs-var">floated_eqs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101409"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101409"><span class="hs-identifier hs-var">implics2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Bag Implication -&gt; TcS (Cts, Bag Implication)
</span><a href="GHC.Tc.Solver.html#solveNestedImplications"><span class="hs-identifier hs-var">solveNestedImplications</span></a></span><span> </span><span class="annot"><span class="annottext">(Bag Implication -&gt; TcS (Cts, Bag Implication))
-&gt; Bag Implication -&gt; TcS (Cts, Bag Implication)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1627"></span><span>                                    </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101416"><span class="hs-identifier hs-var">implics</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication -&gt; Bag Implication -&gt; Bag Implication
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var hs-var">wc_impl</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101412"><span class="hs-identifier hs-var">wc1</span></a></span><span>
</span><span id="line-1628"></span><span>
</span><span id="line-1629"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101407"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681101407"><span class="hs-identifier hs-var">dflags</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-1630"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101406"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101406"><span class="hs-identifier hs-var">solved_wc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int
-&gt; IntWithInf -&gt; Cts -&gt; WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#simpl_loop"><span class="hs-identifier hs-var">simpl_loop</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; IntWithInf
</span><a href="GHC.Driver.Session.html#solverIterations"><span class="hs-identifier hs-var hs-var">solverIterations</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681101407"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101410"><span class="hs-identifier hs-var">floated_eqs</span></a></span><span>
</span><span id="line-1631"></span><span>                                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101412"><span class="hs-identifier hs-var">wc1</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_impl :: Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101409"><span class="hs-identifier hs-var">implics2</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1632"></span><span>
</span><span id="line-1633"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101403"><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681101403"><span class="hs-identifier hs-var">holes'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Bag Hole -&gt; TcS (Bag Hole)
</span><a href="GHC.Tc.Solver.html#simplifyHoles"><span class="hs-identifier hs-var">simplifyHoles</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681101415"><span class="hs-identifier hs-var">holes</span></a></span><span>
</span><span id="line-1634"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101401"><span class="annot"><span class="annottext">final_wc :: WantedConstraints
</span><a href="#local-6989586621681101401"><span class="hs-identifier hs-var hs-var">final_wc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101406"><span class="hs-identifier hs-var">solved_wc</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_holes :: Bag Hole
</span><a href="GHC.Tc.Types.Constraint.html#wc_holes"><span class="hs-identifier hs-var">wc_holes</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681101403"><span class="hs-identifier hs-var">holes'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1635"></span><span>
</span><span id="line-1636"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101400"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101400"><span class="hs-identifier hs-var">ev_binds_var</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS EvBindsVar
</span><a href="GHC.Tc.Solver.Monad.html#getTcEvBindsVar"><span class="hs-identifier hs-var">getTcEvBindsVar</span></a></span><span>
</span><span id="line-1637"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101398"><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101398"><span class="hs-identifier hs-var">bb</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; TcS EvBindMap
</span><a href="GHC.Tc.Solver.Monad.html#getTcEvBindsMap"><span class="hs-identifier hs-var">TcS.getTcEvBindsMap</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101400"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span>
</span><span id="line-1638"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;solveWanteds }&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcS ()) -&gt; SDoc -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1639"></span><span>                 </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;final wc =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101401"><span class="hs-identifier hs-var">final_wc</span></a></span><span>
</span><span id="line-1640"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;current evbinds  =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Bag EvBind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EvBindMap -&gt; Bag EvBind
</span><a href="GHC.Tc.Types.Evidence.html#evBindMapBinds"><span class="hs-identifier hs-var">evBindMapBinds</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101398"><span class="hs-identifier hs-var">bb</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1641"></span><span>
</span><span id="line-1642"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101401"><span class="hs-identifier hs-var">final_wc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1643"></span><span>
</span><span id="line-1644"></span><span class="annot"><a href="GHC.Tc.Solver.html#simpl_loop"><span class="hs-identifier hs-type">simpl_loop</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#IntWithInf"><span class="hs-identifier hs-type">IntWithInf</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Cts"><span class="hs-identifier hs-type">Cts</span></a></span><span>
</span><span id="line-1645"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-1646"></span><span id="simpl_loop"><span class="annot"><span class="annottext">simpl_loop :: Int
-&gt; IntWithInf -&gt; Cts -&gt; WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#simpl_loop"><span class="hs-identifier hs-var hs-var">simpl_loop</span></a></span></span><span> </span><span id="local-6989586621681101396"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681101396"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681101395"><span class="annot"><span class="annottext">IntWithInf
</span><a href="#local-6989586621681101395"><span class="hs-identifier hs-var">limit</span></a></span></span><span> </span><span id="local-6989586621681101394"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101394"><span class="hs-identifier hs-var">floated_eqs</span></a></span></span><span> </span><span id="local-6989586621681101393"><span class="annot"><span class="annottext">wc :: WantedConstraints
</span><a href="#local-6989586621681101393"><span class="hs-identifier hs-var">wc</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WC"><span class="hs-identifier hs-type">WC</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: WantedConstraints -&gt; Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101392"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101392"><span class="hs-identifier hs-var">simples</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1647"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681101396"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; IntWithInf -&gt; Bool
</span><a href="GHC.Types.Basic.html#intGtLimit"><span class="hs-operator hs-var">`intGtLimit`</span></a></span><span> </span><span class="annot"><span class="annottext">IntWithInf
</span><a href="#local-6989586621681101395"><span class="hs-identifier hs-var">limit</span></a></span><span>
</span><span id="line-1648"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- Add an error (not a warning) if we blow the limit,</span><span>
</span><span id="line-1649"></span><span>         </span><span class="hs-comment">-- Typically if we blow the limit we are going to report some other error</span><span>
</span><span id="line-1650"></span><span>         </span><span class="hs-comment">-- (an unsolved constraint), and we don't want that error to suppress</span><span>
</span><span id="line-1651"></span><span>         </span><span class="hs-comment">-- the iteration limit warning!</span><span>
</span><span id="line-1652"></span><span>         </span><span class="annot"><span class="annottext">SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#addErrTcS"><span class="hs-identifier hs-var">addErrTcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;solveWanteds: too many iterations&quot;</span></span><span>
</span><span id="line-1653"></span><span>                   </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;limit =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">IntWithInf -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">IntWithInf
</span><a href="#local-6989586621681101395"><span class="hs-identifier hs-var">limit</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1654"></span><span>                </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Unsolved:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101393"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-1655"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppUnless"><span class="hs-identifier hs-var">ppUnless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts -&gt; Bool
forall a. Bag a -&gt; Bool
</span><a href="GHC.Data.Bag.html#isEmptyBag"><span class="hs-identifier hs-var">isEmptyBag</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101394"><span class="hs-identifier hs-var">floated_eqs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1656"></span><span>                          </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Floated equalities:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Cts -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101394"><span class="hs-identifier hs-var">floated_eqs</span></a></span><span>
</span><span id="line-1657"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Set limit with -fconstraint-solver-iterations=n; n=0 for no limit&quot;</span></span><span>
</span><span id="line-1658"></span><span>                  </span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1659"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101393"><span class="hs-identifier hs-var">wc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1660"></span><span>
</span><span id="line-1661"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts -&gt; Bool
forall a. Bag a -&gt; Bool
</span><a href="GHC.Data.Bag.html#isEmptyBag"><span class="hs-identifier hs-var">isEmptyBag</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101394"><span class="hs-identifier hs-var">floated_eqs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1662"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
-&gt; IntWithInf -&gt; Bool -&gt; WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#simplify_again"><span class="hs-identifier hs-var">simplify_again</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681101396"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">IntWithInf
</span><a href="#local-6989586621681101395"><span class="hs-identifier hs-var">limit</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101393"><span class="hs-identifier hs-var">wc</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101394"><span class="hs-identifier hs-var">floated_eqs</span></a></span><span> </span><span class="annot"><span class="annottext">Cts -&gt; Cts -&gt; Cts
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101392"><span class="hs-identifier hs-var">simples</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1663"></span><span>            </span><span class="hs-comment">-- Put floated_eqs first so they get solved first</span><span>
</span><span id="line-1664"></span><span>            </span><span class="hs-comment">-- NB: the floated_eqs may include /derived/ equalities</span><span>
</span><span id="line-1665"></span><span>            </span><span class="hs-comment">-- arising from fundeps inside an implication</span><span>
</span><span id="line-1666"></span><span>
</span><span id="line-1667"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#superClassesMightHelp"><span class="hs-identifier hs-var">superClassesMightHelp</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101393"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-1668"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- We still have unsolved goals, and apparently no way to solve them,</span><span>
</span><span id="line-1669"></span><span>    </span><span class="hs-comment">-- so try expanding superclasses at this level, both Given and Wanted</span><span>
</span><span id="line-1670"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101386"><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101386"><span class="hs-identifier hs-var">pending_given</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS [Ct]
</span><a href="GHC.Tc.Solver.Monad.html#getPendingGivenScs"><span class="hs-identifier hs-var">getPendingGivenScs</span></a></span><span>
</span><span id="line-1671"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101385"><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101385"><span class="hs-identifier hs-var">pending_wanted</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101384"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101384"><span class="hs-identifier hs-var">simples1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts -&gt; ([Ct], Cts)
</span><a href="GHC.Tc.Types.Constraint.html#getPendingWantedScs"><span class="hs-identifier hs-var">getPendingWantedScs</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101392"><span class="hs-identifier hs-var">simples</span></a></span><span>
</span><span id="line-1672"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101386"><span class="hs-identifier hs-var">pending_given</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101385"><span class="hs-identifier hs-var">pending_wanted</span></a></span><span>
</span><span id="line-1673"></span><span>           </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101393"><span class="hs-identifier hs-var">wc</span></a></span><span>  </span><span class="hs-comment">-- After all, superclasses did not help</span><span>
</span><span id="line-1674"></span><span>           </span><span class="hs-keyword">else</span><span>
</span><span id="line-1675"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101382"><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101382"><span class="hs-identifier hs-var">new_given</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#makeSuperClasses"><span class="hs-identifier hs-var">makeSuperClasses</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101386"><span class="hs-identifier hs-var">pending_given</span></a></span><span>
</span><span id="line-1676"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101381"><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101381"><span class="hs-identifier hs-var">new_wanted</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS [Ct]
</span><a href="GHC.Tc.Solver.Canonical.html#makeSuperClasses"><span class="hs-identifier hs-var">makeSuperClasses</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101385"><span class="hs-identifier hs-var">pending_wanted</span></a></span><span>
</span><span id="line-1677"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Interact.html#solveSimpleGivens"><span class="hs-identifier hs-var">solveSimpleGivens</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101382"><span class="hs-identifier hs-var">new_given</span></a></span><span> </span><span class="hs-comment">-- Add the new Givens to the inert set</span><span>
</span><span id="line-1678"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Int
-&gt; IntWithInf -&gt; Bool -&gt; WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#simplify_again"><span class="hs-identifier hs-var">simplify_again</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681101396"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">IntWithInf
</span><a href="#local-6989586621681101395"><span class="hs-identifier hs-var">limit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Ct] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101386"><span class="hs-identifier hs-var">pending_given</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1679"></span><span>         </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101393"><span class="hs-identifier hs-var">wc</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101384"><span class="hs-identifier hs-var">simples1</span></a></span><span> </span><span class="annot"><span class="annottext">Cts -&gt; Cts -&gt; Cts
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; Cts
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101381"><span class="hs-identifier hs-var">new_wanted</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1680"></span><span>
</span><span id="line-1681"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1682"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101393"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-1683"></span><span>
</span><span id="line-1684"></span><span class="annot"><a href="GHC.Tc.Solver.html#simplify_again"><span class="hs-identifier hs-type">simplify_again</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#IntWithInf"><span class="hs-identifier hs-type">IntWithInf</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1685"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-1686"></span><span class="hs-comment">-- We have definitely decided to have another go at solving</span><span>
</span><span id="line-1687"></span><span class="hs-comment">-- the wanted constraints (we have tried at least once already</span><span>
</span><span id="line-1688"></span><span id="simplify_again"><span class="annot"><span class="annottext">simplify_again :: Int
-&gt; IntWithInf -&gt; Bool -&gt; WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#simplify_again"><span class="hs-identifier hs-var hs-var">simplify_again</span></a></span></span><span> </span><span id="local-6989586621681101379"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681101379"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681101378"><span class="annot"><span class="annottext">IntWithInf
</span><a href="#local-6989586621681101378"><span class="hs-identifier hs-var">limit</span></a></span></span><span> </span><span id="local-6989586621681101377"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101377"><span class="hs-identifier hs-var">no_new_given_scs</span></a></span></span><span>
</span><span id="line-1689"></span><span>               </span><span id="local-6989586621681101376"><span class="annot"><span class="annottext">wc :: WantedConstraints
</span><a href="#local-6989586621681101376"><span class="hs-identifier hs-var">wc</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WC"><span class="hs-identifier hs-type">WC</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: WantedConstraints -&gt; Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101375"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101375"><span class="hs-identifier hs-var">simples</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_impl :: WantedConstraints -&gt; Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101374"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101374"><span class="hs-identifier hs-var">implics</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1690"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#csTraceTcS"><span class="hs-identifier hs-var">csTraceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcS ()) -&gt; SDoc -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1691"></span><span>         </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;simpl_loop iteration=&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#int"><span class="hs-identifier hs-var">int</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681101379"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1692"></span><span>         </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hsep"><span class="hs-identifier hs-var">hsep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;no new given superclasses =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101377"><span class="hs-identifier hs-var">no_new_given_scs</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span>
</span><span id="line-1693"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#int"><span class="hs-identifier hs-var">int</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts -&gt; Int
forall a. Bag a -&gt; Int
</span><a href="GHC.Data.Bag.html#lengthBag"><span class="hs-identifier hs-var">lengthBag</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101375"><span class="hs-identifier hs-var">simples</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;simples to solve&quot;</span></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1694"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;simpl_loop: wc =&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101376"><span class="hs-identifier hs-var">wc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1695"></span><span>
</span><span id="line-1696"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101369"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681101369"><span class="hs-identifier hs-var">unifs1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101368"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101368"><span class="hs-identifier hs-var">wc1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS WantedConstraints -&gt; TcS (Int, WantedConstraints)
forall a. TcS a -&gt; TcS (Int, a)
</span><a href="GHC.Tc.Solver.Monad.html#reportUnifications"><span class="hs-identifier hs-var">reportUnifications</span></a></span><span> </span><span class="annot"><span class="annottext">(TcS WantedConstraints -&gt; TcS (Int, WantedConstraints))
-&gt; TcS WantedConstraints -&gt; TcS (Int, WantedConstraints)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1697"></span><span>                          </span><span class="annot"><span class="annottext">Cts -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.Interact.html#solveSimpleWanteds"><span class="hs-identifier hs-var">solveSimpleWanteds</span></a></span><span> </span><span class="annot"><span class="annottext">(Cts -&gt; TcS WantedConstraints) -&gt; Cts -&gt; TcS WantedConstraints
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1698"></span><span>                          </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101375"><span class="hs-identifier hs-var">simples</span></a></span><span>
</span><span id="line-1699"></span><span>
</span><span id="line-1700"></span><span>       </span><span class="hs-comment">-- See Note [Cutting off simpl_loop]</span><span>
</span><span id="line-1701"></span><span>       </span><span class="hs-comment">-- We have already tried to solve the nested implications once</span><span>
</span><span id="line-1702"></span><span>       </span><span class="hs-comment">-- Try again only if we have unified some meta-variables</span><span>
</span><span id="line-1703"></span><span>       </span><span class="hs-comment">-- (which is a bit like adding more givens), or we have some</span><span>
</span><span id="line-1704"></span><span>       </span><span class="hs-comment">-- new Given superclasses</span><span>
</span><span id="line-1705"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101366"><span class="annot"><span class="annottext">new_implics :: Bag Implication
</span><a href="#local-6989586621681101366"><span class="hs-identifier hs-var hs-var">new_implics</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var hs-var">wc_impl</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101368"><span class="hs-identifier hs-var">wc1</span></a></span><span>
</span><span id="line-1706"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681101369"><span class="hs-identifier hs-var">unifs1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>       </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-1707"></span><span>            </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101377"><span class="hs-identifier hs-var">no_new_given_scs</span></a></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-1708"></span><span>            </span><span class="annot"><span class="annottext">Bag Implication -&gt; Bool
forall a. Bag a -&gt; Bool
</span><a href="GHC.Data.Bag.html#isEmptyBag"><span class="hs-identifier hs-var">isEmptyBag</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101366"><span class="hs-identifier hs-var">new_implics</span></a></span><span>
</span><span id="line-1709"></span><span>
</span><span id="line-1710"></span><span>           </span><span class="hs-keyword">then</span><span> </span><span class="hs-comment">-- Do not even try to solve the implications</span><span>
</span><span id="line-1711"></span><span>                </span><span class="annot"><span class="annottext">Int
-&gt; IntWithInf -&gt; Cts -&gt; WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#simpl_loop"><span class="hs-identifier hs-var">simpl_loop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681101379"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IntWithInf
</span><a href="#local-6989586621681101378"><span class="hs-identifier hs-var">limit</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101368"><span class="hs-identifier hs-var">wc1</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_impl :: Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101374"><span class="hs-identifier hs-var">implics</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1712"></span><span>
</span><span id="line-1713"></span><span>           </span><span class="hs-keyword">else</span><span> </span><span class="hs-comment">-- Try to solve the implications</span><span>
</span><span id="line-1714"></span><span>                </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101364"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101364"><span class="hs-identifier hs-var">floated_eqs2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101363"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101363"><span class="hs-identifier hs-var">implics2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Bag Implication -&gt; TcS (Cts, Bag Implication)
</span><a href="GHC.Tc.Solver.html#solveNestedImplications"><span class="hs-identifier hs-var">solveNestedImplications</span></a></span><span> </span><span class="annot"><span class="annottext">(Bag Implication -&gt; TcS (Cts, Bag Implication))
-&gt; Bag Implication -&gt; TcS (Cts, Bag Implication)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1715"></span><span>                                                 </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101374"><span class="hs-identifier hs-var">implics</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication -&gt; Bag Implication -&gt; Bag Implication
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101366"><span class="hs-identifier hs-var">new_implics</span></a></span><span>
</span><span id="line-1716"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Int
-&gt; IntWithInf -&gt; Cts -&gt; WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#simpl_loop"><span class="hs-identifier hs-var">simpl_loop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681101379"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IntWithInf
</span><a href="#local-6989586621681101378"><span class="hs-identifier hs-var">limit</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101364"><span class="hs-identifier hs-var">floated_eqs2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101368"><span class="hs-identifier hs-var">wc1</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_impl :: Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101363"><span class="hs-identifier hs-var">implics2</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1717"></span><span>    </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1718"></span><span>
</span><span id="line-1719"></span><span class="annot"><a href="GHC.Tc.Solver.html#solveNestedImplications"><span class="hs-identifier hs-type">solveNestedImplications</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span>
</span><span id="line-1720"></span><span>                        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Cts"><span class="hs-identifier hs-type">Cts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1721"></span><span class="hs-comment">-- Precondition: the TcS inerts may contain unsolved simples which have</span><span>
</span><span id="line-1722"></span><span class="hs-comment">-- to be converted to givens before we go inside a nested implication.</span><span>
</span><span id="line-1723"></span><span id="solveNestedImplications"><span class="annot"><span class="annottext">solveNestedImplications :: Bag Implication -&gt; TcS (Cts, Bag Implication)
</span><a href="GHC.Tc.Solver.html#solveNestedImplications"><span class="hs-identifier hs-var hs-var">solveNestedImplications</span></a></span></span><span> </span><span id="local-6989586621681101362"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101362"><span class="hs-identifier hs-var">implics</span></a></span></span><span>
</span><span id="line-1724"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bag Implication -&gt; Bool
forall a. Bag a -&gt; Bool
</span><a href="GHC.Data.Bag.html#isEmptyBag"><span class="hs-identifier hs-var">isEmptyBag</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101362"><span class="hs-identifier hs-var">implics</span></a></span><span>
</span><span id="line-1725"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Cts, Bag Implication) -&gt; TcS (Cts, Bag Implication)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag Implication
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1726"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1727"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;solveNestedImplications starting {&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-1728"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101361"><span class="annot"><span class="annottext">Bag Cts
</span><a href="#local-6989586621681101361"><span class="hs-identifier hs-var">floated_eqs_s</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101360"><span class="annot"><span class="annottext">Bag (Maybe Implication)
</span><a href="#local-6989586621681101360"><span class="hs-identifier hs-var">unsolved_implics</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Implication -&gt; TcS (Cts, Maybe Implication))
-&gt; Bag Implication -&gt; TcS (Bag Cts, Bag (Maybe Implication))
forall (m :: * -&gt; *) a b c.
Monad m =&gt;
(a -&gt; m (b, c)) -&gt; Bag a -&gt; m (Bag b, Bag c)
</span><a href="GHC.Data.Bag.html#mapAndUnzipBagM"><span class="hs-identifier hs-var">mapAndUnzipBagM</span></a></span><span> </span><span class="annot"><span class="annottext">Implication -&gt; TcS (Cts, Maybe Implication)
</span><a href="GHC.Tc.Solver.html#solveImplication"><span class="hs-identifier hs-var">solveImplication</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101362"><span class="hs-identifier hs-var">implics</span></a></span><span>
</span><span id="line-1729"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101357"><span class="annot"><span class="annottext">floated_eqs :: Cts
</span><a href="#local-6989586621681101357"><span class="hs-identifier hs-var hs-var">floated_eqs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Cts -&gt; Cts
forall a. Bag (Bag a) -&gt; Bag a
</span><a href="GHC.Data.Bag.html#concatBag"><span class="hs-identifier hs-var">concatBag</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Cts
</span><a href="#local-6989586621681101361"><span class="hs-identifier hs-var">floated_eqs_s</span></a></span><span>
</span><span id="line-1730"></span><span>
</span><span id="line-1731"></span><span>       </span><span class="hs-comment">-- ... and we are back in the original TcS inerts</span><span>
</span><span id="line-1732"></span><span>       </span><span class="hs-comment">-- Notice that the original includes the _insoluble_simples so it was safe to ignore</span><span>
</span><span id="line-1733"></span><span>       </span><span class="hs-comment">-- them in the beginning of this function.</span><span>
</span><span id="line-1734"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;solveNestedImplications end }&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcS ()) -&gt; SDoc -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1735"></span><span>                  </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;all floated_eqs =&quot;</span></span><span>  </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Cts -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101357"><span class="hs-identifier hs-var">floated_eqs</span></a></span><span>
</span><span id="line-1736"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;unsolved_implics =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Bag (Maybe Implication) -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bag (Maybe Implication)
</span><a href="#local-6989586621681101360"><span class="hs-identifier hs-var">unsolved_implics</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1737"></span><span>
</span><span id="line-1738"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Cts, Bag Implication) -&gt; TcS (Cts, Bag Implication)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101357"><span class="hs-identifier hs-var">floated_eqs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag (Maybe Implication) -&gt; Bag Implication
forall a. Bag (Maybe a) -&gt; Bag a
</span><a href="GHC.Data.Bag.html#catBagMaybes"><span class="hs-identifier hs-var">catBagMaybes</span></a></span><span> </span><span class="annot"><span class="annottext">Bag (Maybe Implication)
</span><a href="#local-6989586621681101360"><span class="hs-identifier hs-var">unsolved_implics</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1739"></span><span>
</span><span id="line-1740"></span><span class="annot"><a href="GHC.Tc.Solver.html#solveImplication"><span class="hs-identifier hs-type">solveImplication</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span>    </span><span class="hs-comment">-- Wanted</span><span>
</span><span id="line-1741"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Cts"><span class="hs-identifier hs-type">Cts</span></a></span><span class="hs-special">,</span><span>      </span><span class="hs-comment">-- All wanted or derived floated equalities: var = type</span><span>
</span><span id="line-1742"></span><span>                         </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Simplified implication (empty or singleton)</span><span>
</span><span id="line-1743"></span><span class="hs-comment">-- Precondition: The TcS monad contains an empty worklist and given-only inerts</span><span>
</span><span id="line-1744"></span><span class="hs-comment">-- which after trying to solve this implication we must restore to their original value</span><span>
</span><span id="line-1745"></span><span id="solveImplication"><span class="annot"><span class="annottext">solveImplication :: Implication -&gt; TcS (Cts, Maybe Implication)
</span><a href="GHC.Tc.Solver.html#solveImplication"><span class="hs-identifier hs-var hs-var">solveImplication</span></a></span></span><span> </span><span id="local-6989586621681101355"><span class="annot"><span class="annottext">imp :: Implication
</span><a href="#local-6989586621681101355"><span class="hs-identifier hs-var">imp</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implic"><span class="hs-identifier hs-type">Implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_tclvl :: Implication -&gt; TcLevel
</span><a href="GHC.Tc.Types.Constraint.html#ic_tclvl"><span class="hs-identifier hs-var">ic_tclvl</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101354"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101354"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span>
</span><span id="line-1746"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_binds :: Implication -&gt; EvBindsVar
</span><a href="GHC.Tc.Types.Constraint.html#ic_binds"><span class="hs-identifier hs-var">ic_binds</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101353"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101353"><span class="hs-identifier hs-var">ev_binds_var</span></a></span></span><span>
</span><span id="line-1747"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_skols :: Implication -&gt; [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_skols"><span class="hs-identifier hs-var">ic_skols</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101352"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101352"><span class="hs-identifier hs-var">skols</span></a></span></span><span>
</span><span id="line-1748"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_given :: Implication -&gt; [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_given"><span class="hs-identifier hs-var">ic_given</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101351"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101351"><span class="hs-identifier hs-var">given_ids</span></a></span></span><span>
</span><span id="line-1749"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: Implication -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101350"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101350"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span>
</span><span id="line-1750"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_info :: Implication -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Constraint.html#ic_info"><span class="hs-identifier hs-var">ic_info</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101349"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681101349"><span class="hs-identifier hs-var">info</span></a></span></span><span>
</span><span id="line-1751"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_status :: Implication -&gt; ImplicStatus
</span><a href="GHC.Tc.Types.Constraint.html#ic_status"><span class="hs-identifier hs-var">ic_status</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101348"><span class="annot"><span class="annottext">ImplicStatus
</span><a href="#local-6989586621681101348"><span class="hs-identifier hs-var">status</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1752"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">ImplicStatus -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isSolvedStatus"><span class="hs-identifier hs-var">isSolvedStatus</span></a></span><span> </span><span class="annot"><span class="annottext">ImplicStatus
</span><a href="#local-6989586621681101348"><span class="hs-identifier hs-var">status</span></a></span><span>
</span><span id="line-1753"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Cts, Maybe Implication) -&gt; TcS (Cts, Maybe Implication)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts
</span><a href="GHC.Tc.Types.Constraint.html#emptyCts"><span class="hs-identifier hs-var">emptyCts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Implication -&gt; Maybe Implication
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101355"><span class="hs-identifier hs-var">imp</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Do nothing</span><span>
</span><span id="line-1754"></span><span>
</span><span id="line-1755"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-comment">-- Even for IC_Insoluble it is worth doing more work</span><span>
</span><span id="line-1756"></span><span>               </span><span class="hs-comment">-- The insoluble stuff might be in one sub-implication</span><span>
</span><span id="line-1757"></span><span>               </span><span class="hs-comment">-- and other unsolved goals in another; and we want to</span><span>
</span><span id="line-1758"></span><span>               </span><span class="hs-comment">-- solve the latter as much as possible</span><span>
</span><span id="line-1759"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101346"><span class="annot"><span class="annottext">InertSet
</span><a href="#local-6989586621681101346"><span class="hs-identifier hs-var">inerts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS InertSet
</span><a href="GHC.Tc.Solver.Monad.html#getTcSInerts"><span class="hs-identifier hs-var">getTcSInerts</span></a></span><span>
</span><span id="line-1760"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;solveImplication {&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101355"><span class="hs-identifier hs-var">imp</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Inerts&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">InertSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">InertSet
</span><a href="#local-6989586621681101346"><span class="hs-identifier hs-var">inerts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1761"></span><span>
</span><span id="line-1762"></span><span>       </span><span class="hs-comment">-- commented out; see `where` clause below</span><span>
</span><span id="line-1763"></span><span>       </span><span class="hs-comment">-- ; when debugIsOn check_tc_level</span><span>
</span><span id="line-1764"></span><span>
</span><span id="line-1765"></span><span>         </span><span class="hs-comment">-- Solve the nested constraints</span><span>
</span><span id="line-1766"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101344"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101344"><span class="hs-identifier hs-var">no_given_eqs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101343"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101343"><span class="hs-identifier hs-var">given_insols</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101342"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101342"><span class="hs-identifier hs-var">residual_wanted</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1767"></span><span>            </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EvBindsVar
-&gt; TcLevel
-&gt; TcS (Bool, Cts, WantedConstraints)
-&gt; TcS (Bool, Cts, WantedConstraints)
forall a. EvBindsVar -&gt; TcLevel -&gt; TcS a -&gt; TcS a
</span><a href="GHC.Tc.Solver.Monad.html#nestImplicTcS"><span class="hs-identifier hs-var">nestImplicTcS</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101353"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101354"><span class="hs-identifier hs-var">tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">(TcS (Bool, Cts, WantedConstraints)
 -&gt; TcS (Bool, Cts, WantedConstraints))
-&gt; TcS (Bool, Cts, WantedConstraints)
-&gt; TcS (Bool, Cts, WantedConstraints)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1768"></span><span>               </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101340"><span class="annot"><span class="annottext">loc :: CtLoc
</span><a href="#local-6989586621681101340"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; SkolemInfo -&gt; TcLclEnv -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#mkGivenLoc"><span class="hs-identifier hs-var">mkGivenLoc</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101354"><span class="hs-identifier hs-var">tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681101349"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication -&gt; TcLclEnv
</span><a href="GHC.Tc.Types.Constraint.html#ic_env"><span class="hs-identifier hs-var hs-var">ic_env</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101355"><span class="hs-identifier hs-var">imp</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1769"></span><span>                        </span><span id="local-6989586621681101338"><span class="annot"><span class="annottext">givens :: [Ct]
</span><a href="#local-6989586621681101338"><span class="hs-identifier hs-var hs-var">givens</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; [TcTyVar] -&gt; [Ct]
</span><a href="GHC.Tc.Types.Constraint.html#mkGivens"><span class="hs-identifier hs-var">mkGivens</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681101340"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101351"><span class="hs-identifier hs-var">given_ids</span></a></span><span>
</span><span id="line-1770"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Interact.html#solveSimpleGivens"><span class="hs-identifier hs-var">solveSimpleGivens</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101338"><span class="hs-identifier hs-var">givens</span></a></span><span>
</span><span id="line-1771"></span><span>
</span><span id="line-1772"></span><span>                  </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101337"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101337"><span class="hs-identifier hs-var">residual_wanted</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.html#solveWanteds"><span class="hs-identifier hs-var">solveWanteds</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101350"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-1773"></span><span>                        </span><span class="hs-comment">-- solveWanteds, *not* solveWantedsAndDrop, because</span><span>
</span><span id="line-1774"></span><span>                        </span><span class="hs-comment">-- we want to retain derived equalities so we can float</span><span>
</span><span id="line-1775"></span><span>                        </span><span class="hs-comment">-- them out in floatEqualities</span><span>
</span><span id="line-1776"></span><span>
</span><span id="line-1777"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101336"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101336"><span class="hs-identifier hs-var">no_eqs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101335"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101335"><span class="hs-identifier hs-var">given_insols</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; [TcTyVar] -&gt; TcS (Bool, Cts)
</span><a href="GHC.Tc.Solver.Monad.html#getNoGivenEqs"><span class="hs-identifier hs-var">getNoGivenEqs</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101354"><span class="hs-identifier hs-var">tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101352"><span class="hs-identifier hs-var">skols</span></a></span><span>
</span><span id="line-1778"></span><span>                        </span><span class="hs-comment">-- Call getNoGivenEqs /after/ solveWanteds, because</span><span>
</span><span id="line-1779"></span><span>                        </span><span class="hs-comment">-- solveWanteds can augment the givens, via expandSuperClasses,</span><span>
</span><span id="line-1780"></span><span>                        </span><span class="hs-comment">-- to reveal given superclass equalities</span><span>
</span><span id="line-1781"></span><span>
</span><span id="line-1782"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Bool, Cts, WantedConstraints)
-&gt; TcS (Bool, Cts, WantedConstraints)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101336"><span class="hs-identifier hs-var">no_eqs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101335"><span class="hs-identifier hs-var">given_insols</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101337"><span class="hs-identifier hs-var">residual_wanted</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1783"></span><span>
</span><span id="line-1784"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101333"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101333"><span class="hs-identifier hs-var">floated_eqs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101332"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101332"><span class="hs-identifier hs-var">residual_wanted</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1785"></span><span>             </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
-&gt; [TcTyVar]
-&gt; EvBindsVar
-&gt; Bool
-&gt; WantedConstraints
-&gt; TcS (Cts, WantedConstraints)
</span><a href="GHC.Tc.Solver.html#floatEqualities"><span class="hs-identifier hs-var">floatEqualities</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101352"><span class="hs-identifier hs-var">skols</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101351"><span class="hs-identifier hs-var">given_ids</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101353"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span>
</span><span id="line-1786"></span><span>                                </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101344"><span class="hs-identifier hs-var">no_given_eqs</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101342"><span class="hs-identifier hs-var">residual_wanted</span></a></span><span>
</span><span id="line-1787"></span><span>
</span><span id="line-1788"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;solveImplication 2&quot;</span></span><span>
</span><span id="line-1789"></span><span>           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101343"><span class="hs-identifier hs-var">given_insols</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101332"><span class="hs-identifier hs-var">residual_wanted</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1790"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101330"><span class="annot"><span class="annottext">final_wanted :: WantedConstraints
</span><a href="#local-6989586621681101330"><span class="hs-identifier hs-var hs-var">final_wanted</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101332"><span class="hs-identifier hs-var">residual_wanted</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Cts -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#addInsols"><span class="hs-operator hs-var">`addInsols`</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101343"><span class="hs-identifier hs-var">given_insols</span></a></span><span>
</span><span id="line-1791"></span><span>             </span><span class="hs-comment">-- Don't lose track of the insoluble givens,</span><span>
</span><span id="line-1792"></span><span>             </span><span class="hs-comment">-- which signal unreachable code; put them in ic_wanted</span><span>
</span><span id="line-1793"></span><span>
</span><span id="line-1794"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101328"><span class="annot"><span class="annottext">Maybe Implication
</span><a href="#local-6989586621681101328"><span class="hs-identifier hs-var">res_implic</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Implication -&gt; TcS (Maybe Implication)
</span><a href="GHC.Tc.Solver.html#setImplicationStatus"><span class="hs-identifier hs-var">setImplicationStatus</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101355"><span class="hs-identifier hs-var">imp</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_no_eqs :: Bool
</span><a href="GHC.Tc.Types.Constraint.html#ic_no_eqs"><span class="hs-identifier hs-var">ic_no_eqs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101344"><span class="hs-identifier hs-var">no_given_eqs</span></a></span><span>
</span><span id="line-1795"></span><span>                                                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101330"><span class="hs-identifier hs-var">final_wanted</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1796"></span><span>
</span><span id="line-1797"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101327"><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101327"><span class="hs-identifier hs-var">evbinds</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; TcS EvBindMap
</span><a href="GHC.Tc.Solver.Monad.html#getTcEvBindsMap"><span class="hs-identifier hs-var">TcS.getTcEvBindsMap</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101353"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span>
</span><span id="line-1798"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101326"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101326"><span class="hs-identifier hs-var">tcvs</span></a></span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; TcS VarSet
</span><a href="GHC.Tc.Solver.Monad.html#getTcEvTyCoVars"><span class="hs-identifier hs-var">TcS.getTcEvTyCoVars</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101353"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span>
</span><span id="line-1799"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;solveImplication end }&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcS ()) -&gt; SDoc -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span>
</span><span id="line-1800"></span><span>             </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;no_given_eqs =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101344"><span class="hs-identifier hs-var">no_given_eqs</span></a></span><span>
</span><span id="line-1801"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;floated_eqs =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Cts -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101333"><span class="hs-identifier hs-var">floated_eqs</span></a></span><span>
</span><span id="line-1802"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;res_implic =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Implication -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Implication
</span><a href="#local-6989586621681101328"><span class="hs-identifier hs-var">res_implic</span></a></span><span>
</span><span id="line-1803"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;implication evbinds =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Bag EvBind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EvBindMap -&gt; Bag EvBind
</span><a href="GHC.Tc.Types.Evidence.html#evBindMapBinds"><span class="hs-identifier hs-var">evBindMapBinds</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101327"><span class="hs-identifier hs-var">evbinds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1804"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;implication tvcs =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101326"><span class="hs-identifier hs-var">tcvs</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1805"></span><span>
</span><span id="line-1806"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Cts, Maybe Implication) -&gt; TcS (Cts, Maybe Implication)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101333"><span class="hs-identifier hs-var">floated_eqs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe Implication
</span><a href="#local-6989586621681101328"><span class="hs-identifier hs-var">res_implic</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1807"></span><span>
</span><span id="line-1808"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1809"></span><span>    </span><span class="hs-comment">-- TcLevels must be strictly increasing (see (ImplicInv) in</span><span>
</span><span id="line-1810"></span><span>    </span><span class="hs-comment">-- Note [TcLevel and untouchable type variables] in GHC.Tc.Utils.TcType),</span><span>
</span><span id="line-1811"></span><span>    </span><span class="hs-comment">-- and in fact I think they should always increase one level at a time.</span><span>
</span><span id="line-1812"></span><span>
</span><span id="line-1813"></span><span>    </span><span class="hs-comment">-- Though sensible, this check causes lots of testsuite failures. It is</span><span>
</span><span id="line-1814"></span><span>    </span><span class="hs-comment">-- remaining commented out for now.</span><span>
</span><span id="line-1815"></span><span>    </span><span class="hs-comment">{-
    check_tc_level = do { cur_lvl &lt;- TcS.getTcLevel
                        ; MASSERT2( tclvl == pushTcLevel cur_lvl , text &quot;Cur lvl =&quot; &lt;+&gt; ppr cur_lvl $$ text &quot;Imp lvl =&quot; &lt;+&gt; ppr tclvl ) }
    -}</span><span>
</span><span id="line-1819"></span><span>
</span><span id="line-1820"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-1821"></span><span class="annot"><a href="GHC.Tc.Solver.html#setImplicationStatus"><span class="hs-identifier hs-type">setImplicationStatus</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1822"></span><span class="hs-comment">-- Finalise the implication returned from solveImplication:</span><span>
</span><span id="line-1823"></span><span class="hs-comment">--    * Set the ic_status field</span><span>
</span><span id="line-1824"></span><span class="hs-comment">--    * Trim the ic_wanted field to remove Derived constraints</span><span>
</span><span id="line-1825"></span><span class="hs-comment">-- Precondition: the ic_status field is not already IC_Solved</span><span>
</span><span id="line-1826"></span><span class="hs-comment">-- Return Nothing if we can discard the implication altogether</span><span>
</span><span id="line-1827"></span><span id="setImplicationStatus"><span class="annot"><span class="annottext">setImplicationStatus :: Implication -&gt; TcS (Maybe Implication)
</span><a href="GHC.Tc.Solver.html#setImplicationStatus"><span class="hs-identifier hs-var hs-var">setImplicationStatus</span></a></span></span><span> </span><span id="local-6989586621681101324"><span class="annot"><span class="annottext">implic :: Implication
</span><a href="#local-6989586621681101324"><span class="hs-identifier hs-var">implic</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implic"><span class="hs-identifier hs-type">Implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_status :: Implication -&gt; ImplicStatus
</span><a href="GHC.Tc.Types.Constraint.html#ic_status"><span class="hs-identifier hs-var">ic_status</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101323"><span class="annot"><span class="annottext">ImplicStatus
</span><a href="#local-6989586621681101323"><span class="hs-identifier hs-var">status</span></a></span></span><span>
</span><span id="line-1828"></span><span>                                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_info :: Implication -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Constraint.html#ic_info"><span class="hs-identifier hs-var">ic_info</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101322"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681101322"><span class="hs-identifier hs-var">info</span></a></span></span><span>
</span><span id="line-1829"></span><span>                                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: Implication -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101321"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101321"><span class="hs-identifier hs-var">wc</span></a></span></span><span>
</span><span id="line-1830"></span><span>                                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_given :: Implication -&gt; [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_given"><span class="hs-identifier hs-var">ic_given</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101320"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101320"><span class="hs-identifier hs-var">givens</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1831"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isSolvedStatus</span><span> </span><span class="hs-identifier">status</span><span> </span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">info</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1832"></span><span>   </span><span class="hs-comment">-- Precondition: we only set the status if it is not already solved</span><span>
</span><span id="line-1833"></span><span>   </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isSolvedWC"><span class="hs-identifier hs-var">isSolvedWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101318"><span class="hs-identifier hs-var">pruned_wc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1834"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;setImplicationStatus(not-all-solved) {&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101324"><span class="hs-identifier hs-var">implic</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1835"></span><span>
</span><span id="line-1836"></span><span>      </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101317"><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101317"><span class="hs-identifier hs-var">implic</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Implication -&gt; TcS Implication
</span><a href="GHC.Tc.Solver.html#neededEvVars"><span class="hs-identifier hs-var">neededEvVars</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101324"><span class="hs-identifier hs-var">implic</span></a></span><span>
</span><span id="line-1837"></span><span>
</span><span id="line-1838"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101315"><span class="annot"><span class="annottext">new_status :: ImplicStatus
</span><a href="#local-6989586621681101315"><span class="hs-identifier hs-var hs-var">new_status</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#insolubleWC"><span class="hs-identifier hs-var">insolubleWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101318"><span class="hs-identifier hs-var">pruned_wc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ImplicStatus
</span><a href="GHC.Tc.Types.Constraint.html#IC_Insoluble"><span class="hs-identifier hs-var">IC_Insoluble</span></a></span><span>
</span><span id="line-1839"></span><span>                       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ImplicStatus
</span><a href="GHC.Tc.Types.Constraint.html#IC_Unsolved"><span class="hs-identifier hs-var">IC_Unsolved</span></a></span><span>
</span><span id="line-1840"></span><span>            </span><span id="local-6989586621681101312"><span class="annot"><span class="annottext">new_implic :: Implication
</span><a href="#local-6989586621681101312"><span class="hs-identifier hs-var hs-var">new_implic</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101317"><span class="hs-identifier hs-var">implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_status :: ImplicStatus
</span><a href="GHC.Tc.Types.Constraint.html#ic_status"><span class="hs-identifier hs-var">ic_status</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ImplicStatus
</span><a href="#local-6989586621681101315"><span class="hs-identifier hs-var">new_status</span></a></span><span>
</span><span id="line-1841"></span><span>                                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101318"><span class="hs-identifier hs-var">pruned_wc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1842"></span><span>
</span><span id="line-1843"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;setImplicationStatus(not-all-solved) }&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101312"><span class="hs-identifier hs-var">new_implic</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1844"></span><span>
</span><span id="line-1845"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe Implication -&gt; TcS (Maybe Implication)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Implication -&gt; TcS (Maybe Implication))
-&gt; Maybe Implication -&gt; TcS (Maybe Implication)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Implication -&gt; Maybe Implication
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101312"><span class="hs-identifier hs-var">new_implic</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1846"></span><span>
</span><span id="line-1847"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-comment">-- Everything is solved</span><span>
</span><span id="line-1848"></span><span>              </span><span class="hs-comment">-- Set status to IC_Solved,</span><span>
</span><span id="line-1849"></span><span>              </span><span class="hs-comment">-- and compute the dead givens and outer needs</span><span>
</span><span id="line-1850"></span><span>              </span><span class="hs-comment">-- See Note [Tracking redundant constraints]</span><span>
</span><span id="line-1851"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;setImplicationStatus(all-solved) {&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101324"><span class="hs-identifier hs-var">implic</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1852"></span><span>
</span><span id="line-1853"></span><span>      </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101311"><span class="annot"><span class="annottext">implic :: Implication
</span><a href="#local-6989586621681101311"><span class="hs-identifier hs-var">implic</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implic"><span class="hs-identifier hs-type">Implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_need_inner :: Implication -&gt; VarSet
</span><a href="GHC.Tc.Types.Constraint.html#ic_need_inner"><span class="hs-identifier hs-var">ic_need_inner</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101309"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101309"><span class="hs-identifier hs-var">need_inner</span></a></span></span><span>
</span><span id="line-1854"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_need_outer :: Implication -&gt; VarSet
</span><a href="GHC.Tc.Types.Constraint.html#ic_need_outer"><span class="hs-identifier hs-var">ic_need_outer</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101307"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101307"><span class="hs-identifier hs-var">need_outer</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Implication -&gt; TcS Implication
</span><a href="GHC.Tc.Solver.html#neededEvVars"><span class="hs-identifier hs-var">neededEvVars</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101324"><span class="hs-identifier hs-var">implic</span></a></span><span>
</span><span id="line-1855"></span><span>
</span><span id="line-1856"></span><span>      </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101306"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101306"><span class="hs-identifier hs-var">bad_telescope</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Implication -&gt; TcS Bool
</span><a href="GHC.Tc.Solver.html#checkBadTelescope"><span class="hs-identifier hs-var">checkBadTelescope</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101311"><span class="hs-identifier hs-var">implic</span></a></span><span>
</span><span id="line-1857"></span><span>
</span><span id="line-1858"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101304"><span class="annot"><span class="annottext">dead_givens :: [TcTyVar]
</span><a href="#local-6989586621681101304"><span class="hs-identifier hs-var hs-var">dead_givens</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">SkolemInfo -&gt; Bool
</span><a href="GHC.Tc.Solver.html#warnRedundantGivens"><span class="hs-identifier hs-var">warnRedundantGivens</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681101322"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-1859"></span><span>                        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcTyVar -&gt; Bool) -&gt; [TcTyVar] -&gt; [TcTyVar]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="GHC.Utils.Misc.html#filterOut"><span class="hs-identifier hs-var">filterOut</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101309"><span class="hs-identifier hs-var">need_inner</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101320"><span class="hs-identifier hs-var">givens</span></a></span><span>
</span><span id="line-1860"></span><span>                        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>   </span><span class="hs-comment">-- None to report</span><span>
</span><span id="line-1861"></span><span>
</span><span id="line-1862"></span><span>            </span><span id="local-6989586621681101300"><span class="annot"><span class="annottext">discard_entire_implication :: Bool
</span><a href="#local-6989586621681101300"><span class="hs-identifier hs-var hs-var">discard_entire_implication</span></a></span></span><span>  </span><span class="hs-comment">-- Can we discard the entire implication?</span><span>
</span><span id="line-1863"></span><span>              </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101304"><span class="hs-identifier hs-var">dead_givens</span></a></span><span>           </span><span class="hs-comment">-- No warning from this implication</span><span>
</span><span id="line-1864"></span><span>              </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101306"><span class="hs-identifier hs-var">bad_telescope</span></a></span><span>
</span><span id="line-1865"></span><span>              </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isEmptyWC"><span class="hs-identifier hs-var">isEmptyWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101318"><span class="hs-identifier hs-var">pruned_wc</span></a></span><span>        </span><span class="hs-comment">-- No live children</span><span>
</span><span id="line-1866"></span><span>              </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#isEmptyVarSet"><span class="hs-identifier hs-var">isEmptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101307"><span class="hs-identifier hs-var">need_outer</span></a></span><span>   </span><span class="hs-comment">-- No needed vars to pass up to parent</span><span>
</span><span id="line-1867"></span><span>
</span><span id="line-1868"></span><span>            </span><span id="local-6989586621681101298"><span class="annot"><span class="annottext">final_status :: ImplicStatus
</span><a href="#local-6989586621681101298"><span class="hs-identifier hs-var hs-var">final_status</span></a></span></span><span>
</span><span id="line-1869"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101306"><span class="hs-identifier hs-var">bad_telescope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ImplicStatus
</span><a href="GHC.Tc.Types.Constraint.html#IC_BadTelescope"><span class="hs-identifier hs-var">IC_BadTelescope</span></a></span><span>
</span><span id="line-1870"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IC_Solved :: [TcTyVar] -&gt; ImplicStatus
</span><a href="GHC.Tc.Types.Constraint.html#IC_Solved"><span class="hs-identifier hs-type">IC_Solved</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ics_dead :: [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ics_dead"><span class="hs-identifier hs-var">ics_dead</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101304"><span class="hs-identifier hs-var">dead_givens</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1871"></span><span>            </span><span id="local-6989586621681101294"><span class="annot"><span class="annottext">final_implic :: Implication
</span><a href="#local-6989586621681101294"><span class="hs-identifier hs-var hs-var">final_implic</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101311"><span class="hs-identifier hs-var">implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_status :: ImplicStatus
</span><a href="GHC.Tc.Types.Constraint.html#ic_status"><span class="hs-identifier hs-var">ic_status</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ImplicStatus
</span><a href="#local-6989586621681101298"><span class="hs-identifier hs-var">final_status</span></a></span><span>
</span><span id="line-1872"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101318"><span class="hs-identifier hs-var">pruned_wc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1873"></span><span>
</span><span id="line-1874"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;setImplicationStatus(all-solved) }&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcS ()) -&gt; SDoc -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1875"></span><span>        </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;discard:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101300"><span class="hs-identifier hs-var">discard_entire_implication</span></a></span><span>
</span><span id="line-1876"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;new_implic:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Implication -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101294"><span class="hs-identifier hs-var">final_implic</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1877"></span><span>
</span><span id="line-1878"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe Implication -&gt; TcS (Maybe Implication)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Implication -&gt; TcS (Maybe Implication))
-&gt; Maybe Implication -&gt; TcS (Maybe Implication)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101300"><span class="hs-identifier hs-var">discard_entire_implication</span></a></span><span>
</span><span id="line-1879"></span><span>                 </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe Implication
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1880"></span><span>                 </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Implication -&gt; Maybe Implication
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101294"><span class="hs-identifier hs-var">final_implic</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1881"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1882"></span><span>   </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WC"><span class="hs-identifier hs-type">WC</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: WantedConstraints -&gt; Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101293"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101293"><span class="hs-identifier hs-var">simples</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_impl :: WantedConstraints -&gt; Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101292"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101292"><span class="hs-identifier hs-var">implics</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_holes :: WantedConstraints -&gt; Bag Hole
</span><a href="GHC.Tc.Types.Constraint.html#wc_holes"><span class="hs-identifier hs-var">wc_holes</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101291"><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681101291"><span class="hs-identifier hs-var">holes</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101321"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-1883"></span><span>
</span><span id="line-1884"></span><span>   </span><span id="local-6989586621681101290"><span class="annot"><span class="annottext">pruned_simples :: Cts
</span><a href="#local-6989586621681101290"><span class="hs-identifier hs-var hs-var">pruned_simples</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts -&gt; Cts
</span><a href="GHC.Tc.Types.Constraint.html#dropDerivedSimples"><span class="hs-identifier hs-var">dropDerivedSimples</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101293"><span class="hs-identifier hs-var">simples</span></a></span><span>
</span><span id="line-1885"></span><span>   </span><span id="local-6989586621681101288"><span class="annot"><span class="annottext">pruned_implics :: Bag Implication
</span><a href="#local-6989586621681101288"><span class="hs-identifier hs-var hs-var">pruned_implics</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Implication -&gt; Bool) -&gt; Bag Implication -&gt; Bag Implication
forall a. (a -&gt; Bool) -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#filterBag"><span class="hs-identifier hs-var">filterBag</span></a></span><span> </span><span class="annot"><span class="annottext">Implication -&gt; Bool
</span><a href="#local-6989586621681101286"><span class="hs-identifier hs-var">keep_me</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101292"><span class="hs-identifier hs-var">implics</span></a></span><span>
</span><span id="line-1886"></span><span>   </span><span id="local-6989586621681101318"><span class="annot"><span class="annottext">pruned_wc :: WantedConstraints
</span><a href="#local-6989586621681101318"><span class="hs-identifier hs-var hs-var">pruned_wc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WC :: Cts -&gt; Bag Implication -&gt; Bag Hole -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#WC"><span class="hs-identifier hs-type">WC</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101290"><span class="hs-identifier hs-var">pruned_simples</span></a></span><span>
</span><span id="line-1887"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_impl :: Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101288"><span class="hs-identifier hs-var">pruned_implics</span></a></span><span>
</span><span id="line-1888"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_holes :: Bag Hole
</span><a href="GHC.Tc.Types.Constraint.html#wc_holes"><span class="hs-identifier hs-var">wc_holes</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681101291"><span class="hs-identifier hs-var">holes</span></a></span><span> </span><span class="hs-special">}</span><span>   </span><span class="hs-comment">-- do not prune holes; these should be reported</span><span>
</span><span id="line-1889"></span><span>
</span><span id="line-1890"></span><span>   </span><span class="annot"><a href="#local-6989586621681101286"><span class="hs-identifier hs-type">keep_me</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1891"></span><span>   </span><span id="local-6989586621681101286"><span class="annot"><span class="annottext">keep_me :: Implication -&gt; Bool
</span><a href="#local-6989586621681101286"><span class="hs-identifier hs-var hs-var">keep_me</span></a></span></span><span> </span><span id="local-6989586621681101285"><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101285"><span class="hs-identifier hs-var">ic</span></a></span></span><span>
</span><span id="line-1892"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#IC_Solved"><span class="hs-identifier hs-type">IC_Solved</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ics_dead :: ImplicStatus -&gt; [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ics_dead"><span class="hs-identifier hs-var">ics_dead</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101284"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101284"><span class="hs-identifier hs-var">dead_givens</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Implication -&gt; ImplicStatus
</span><a href="GHC.Tc.Types.Constraint.html#ic_status"><span class="hs-identifier hs-var hs-var">ic_status</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101285"><span class="hs-identifier hs-var">ic</span></a></span><span>
</span><span id="line-1893"></span><span>                          </span><span class="hs-comment">-- Fully solved</span><span>
</span><span id="line-1894"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101284"><span class="hs-identifier hs-var">dead_givens</span></a></span><span>   </span><span class="hs-comment">-- No redundant givens to report</span><span>
</span><span id="line-1895"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag Implication -&gt; Bool
forall a. Bag a -&gt; Bool
</span><a href="GHC.Data.Bag.html#isEmptyBag"><span class="hs-identifier hs-var">isEmptyBag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var hs-var">wc_impl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var hs-var">ic_wanted</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101285"><span class="hs-identifier hs-var">ic</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1896"></span><span>           </span><span class="hs-comment">-- And no children that might have things to report</span><span>
</span><span id="line-1897"></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>       </span><span class="hs-comment">-- Tnen we don't need to keep it</span><span>
</span><span id="line-1898"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1899"></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>        </span><span class="hs-comment">-- Otherwise, keep it</span><span>
</span><span id="line-1900"></span><span>
</span><span id="line-1901"></span><span class="annot"><a href="GHC.Tc.Solver.html#checkBadTelescope"><span class="hs-identifier hs-type">checkBadTelescope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1902"></span><span class="hs-comment">-- True &lt;=&gt; the skolems form a bad telescope</span><span>
</span><span id="line-1903"></span><span class="hs-comment">-- See Note [Checking telescopes] in GHC.Tc.Types.Constraint</span><span>
</span><span id="line-1904"></span><span id="checkBadTelescope"><span class="annot"><span class="annottext">checkBadTelescope :: Implication -&gt; TcS Bool
</span><a href="GHC.Tc.Solver.html#checkBadTelescope"><span class="hs-identifier hs-var hs-var">checkBadTelescope</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implic"><span class="hs-identifier hs-type">Implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_info :: Implication -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Constraint.html#ic_info"><span class="hs-identifier hs-var">ic_info</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101283"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681101283"><span class="hs-identifier hs-var">info</span></a></span></span><span>
</span><span id="line-1905"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_skols :: Implication -&gt; [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_skols"><span class="hs-identifier hs-var">ic_skols</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101282"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101282"><span class="hs-identifier hs-var">skols</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1906"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#ForAllSkol"><span class="hs-identifier hs-type">ForAllSkol</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681101283"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-1907"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101280"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101280"><span class="hs-identifier hs-var">skols</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TcTyVar -&gt; TcS TcTyVar) -&gt; [TcTyVar] -&gt; TcS [TcTyVar]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcS TcTyVar
</span><a href="GHC.Tc.Solver.Monad.html#zonkTyCoVarKind"><span class="hs-identifier hs-var">TcS.zonkTyCoVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101282"><span class="hs-identifier hs-var">skols</span></a></span><span>
</span><span id="line-1908"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcS Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; [TcTyVar] -&gt; Bool
</span><a href="#local-6989586621681101278"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcTyVar] -&gt; [TcTyVar]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101280"><span class="hs-identifier hs-var">skols</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">}</span><span>
</span><span id="line-1909"></span><span>
</span><span id="line-1910"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1911"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcS Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1912"></span><span>
</span><span id="line-1913"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1914"></span><span>    </span><span class="annot"><a href="#local-6989586621681101278"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyVarSet"><span class="hs-identifier hs-type">TyVarSet</span></a></span><span>   </span><span class="hs-comment">-- skolems that appear *later* than the current ones</span><span>
</span><span id="line-1915"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span>  </span><span class="hs-comment">-- ordered skolems, in reverse order</span><span>
</span><span id="line-1916"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>       </span><span class="hs-comment">-- True &lt;=&gt; there is an out-of-order skolem</span><span>
</span><span id="line-1917"></span><span>    </span><span id="local-6989586621681101278"><span class="annot"><span class="annottext">go :: VarSet -&gt; [TcTyVar] -&gt; Bool
</span><a href="#local-6989586621681101278"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1918"></span><span>    </span><span class="annot"><a href="#local-6989586621681101278"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681101275"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101275"><span class="hs-identifier hs-var">later_skols</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101274"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101274"><span class="hs-identifier hs-var">one_skol</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681101273"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101273"><span class="hs-identifier hs-var">earlier_skols</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1919"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; Type
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101274"><span class="hs-identifier hs-var">one_skol</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#intersectsVarSet"><span class="hs-operator hs-var">`intersectsVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101275"><span class="hs-identifier hs-var">later_skols</span></a></span><span>
</span><span id="line-1920"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1921"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1922"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; [TcTyVar] -&gt; Bool
</span><a href="#local-6989586621681101278"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101275"><span class="hs-identifier hs-var">later_skols</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; TcTyVar -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-operator hs-var">`extendVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101274"><span class="hs-identifier hs-var">one_skol</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101273"><span class="hs-identifier hs-var">earlier_skols</span></a></span><span>
</span><span id="line-1923"></span><span>
</span><span id="line-1924"></span><span class="annot"><a href="GHC.Tc.Solver.html#warnRedundantGivens"><span class="hs-identifier hs-type">warnRedundantGivens</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SkolemInfo"><span class="hs-identifier hs-type">SkolemInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1925"></span><span id="warnRedundantGivens"><span class="annot"><span class="annottext">warnRedundantGivens :: SkolemInfo -&gt; Bool
</span><a href="GHC.Tc.Solver.html#warnRedundantGivens"><span class="hs-identifier hs-var hs-var">warnRedundantGivens</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SigSkol"><span class="hs-identifier hs-type">SigSkol</span></a></span><span> </span><span id="local-6989586621681101269"><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681101269"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[(Name, TcTyVar)]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-1926"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681101269"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1927"></span><span>       </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#FunSigCtxt"><span class="hs-identifier hs-type">FunSigCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681101267"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101267"><span class="hs-identifier hs-var">warn_redundant</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101267"><span class="hs-identifier hs-var">warn_redundant</span></a></span><span>
</span><span id="line-1928"></span><span>       </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="GHC.Tc.Types.Origin.html#ExprSigCtxt"><span class="hs-identifier hs-var">ExprSigCtxt</span></a></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1929"></span><span>       </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><span class="hs-identifier">_</span></span><span>                           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1930"></span><span>
</span><span id="line-1931"></span><span>  </span><span class="hs-comment">-- To think about: do we want to report redundant givens for</span><span>
</span><span id="line-1932"></span><span>  </span><span class="hs-comment">-- pattern synonyms, PatSynSigSkol? c.f #9953, comment:21.</span><span>
</span><span id="line-1933"></span><span class="annot"><a href="GHC.Tc.Solver.html#warnRedundantGivens"><span class="hs-identifier hs-var">warnRedundantGivens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Origin.html#InstSkol"><span class="hs-identifier hs-type">InstSkol</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1934"></span><span class="annot"><a href="GHC.Tc.Solver.html#warnRedundantGivens"><span class="hs-identifier hs-var">warnRedundantGivens</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><span class="hs-identifier">_</span></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1935"></span><span>
</span><span id="line-1936"></span><span class="annot"><a href="GHC.Tc.Solver.html#neededEvVars"><span class="hs-identifier hs-type">neededEvVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span>
</span><span id="line-1937"></span><span class="hs-comment">-- Find all the evidence variables that are &quot;needed&quot;,</span><span>
</span><span id="line-1938"></span><span class="hs-comment">-- and delete dead evidence bindings</span><span>
</span><span id="line-1939"></span><span class="hs-comment">--   See Note [Tracking redundant constraints]</span><span>
</span><span id="line-1940"></span><span class="hs-comment">--   See Note [Delete dead Given evidence bindings]</span><span>
</span><span id="line-1941"></span><span class="hs-comment">--</span><span>
</span><span id="line-1942"></span><span class="hs-comment">--   - Start from initial_seeds (from nested implications)</span><span>
</span><span id="line-1943"></span><span class="hs-comment">--</span><span>
</span><span id="line-1944"></span><span class="hs-comment">--   - Add free vars of RHS of all Wanted evidence bindings</span><span>
</span><span id="line-1945"></span><span class="hs-comment">--     and coercion variables accumulated in tcvs (all Wanted)</span><span>
</span><span id="line-1946"></span><span class="hs-comment">--</span><span>
</span><span id="line-1947"></span><span class="hs-comment">--   - Generate 'needed', the needed set of EvVars, by doing transitive</span><span>
</span><span id="line-1948"></span><span class="hs-comment">--     closure through Given bindings</span><span>
</span><span id="line-1949"></span><span class="hs-comment">--     e.g.   Needed {a,b}</span><span>
</span><span id="line-1950"></span><span class="hs-comment">--            Given  a = sc_sel a2</span><span>
</span><span id="line-1951"></span><span class="hs-comment">--            Then a2 is needed too</span><span>
</span><span id="line-1952"></span><span class="hs-comment">--</span><span>
</span><span id="line-1953"></span><span class="hs-comment">--   - Prune out all Given bindings that are not needed</span><span>
</span><span id="line-1954"></span><span class="hs-comment">--</span><span>
</span><span id="line-1955"></span><span class="hs-comment">--   - From the 'needed' set, delete ev_bndrs, the binders of the</span><span>
</span><span id="line-1956"></span><span class="hs-comment">--     evidence bindings, to give the final needed variables</span><span>
</span><span id="line-1957"></span><span class="hs-comment">--</span><span>
</span><span id="line-1958"></span><span id="neededEvVars"><span class="annot"><span class="annottext">neededEvVars :: Implication -&gt; TcS Implication
</span><a href="GHC.Tc.Solver.html#neededEvVars"><span class="hs-identifier hs-var hs-var">neededEvVars</span></a></span></span><span> </span><span id="local-6989586621681101264"><span class="annot"><span class="annottext">implic :: Implication
</span><a href="#local-6989586621681101264"><span class="hs-identifier hs-var">implic</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implic"><span class="hs-identifier hs-type">Implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_given :: Implication -&gt; [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_given"><span class="hs-identifier hs-var">ic_given</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101263"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101263"><span class="hs-identifier hs-var">givens</span></a></span></span><span>
</span><span id="line-1959"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_binds :: Implication -&gt; EvBindsVar
</span><a href="GHC.Tc.Types.Constraint.html#ic_binds"><span class="hs-identifier hs-var">ic_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101262"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101262"><span class="hs-identifier hs-var">ev_binds_var</span></a></span></span><span>
</span><span id="line-1960"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: Implication -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WC"><span class="hs-identifier hs-type">WC</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_impl :: WantedConstraints -&gt; Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101261"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101261"><span class="hs-identifier hs-var">implics</span></a></span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1961"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_need_inner :: Implication -&gt; VarSet
</span><a href="GHC.Tc.Types.Constraint.html#ic_need_inner"><span class="hs-identifier hs-var">ic_need_inner</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101260"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101260"><span class="hs-identifier hs-var">old_needs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1962"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101259"><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101259"><span class="hs-identifier hs-var">ev_binds</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; TcS EvBindMap
</span><a href="GHC.Tc.Solver.Monad.html#getTcEvBindsMap"><span class="hs-identifier hs-var">TcS.getTcEvBindsMap</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101262"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span>
</span><span id="line-1963"></span><span>      </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101258"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101258"><span class="hs-identifier hs-var">tcvs</span></a></span></span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; TcS VarSet
</span><a href="GHC.Tc.Solver.Monad.html#getTcEvTyCoVars"><span class="hs-identifier hs-var">TcS.getTcEvTyCoVars</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101262"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span>
</span><span id="line-1964"></span><span>
</span><span id="line-1965"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101256"><span class="annot"><span class="annottext">seeds1 :: VarSet
</span><a href="#local-6989586621681101256"><span class="hs-identifier hs-var hs-var">seeds1</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Implication -&gt; VarSet -&gt; VarSet)
-&gt; VarSet -&gt; Bag Implication -&gt; VarSet
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">Implication -&gt; VarSet -&gt; VarSet
</span><a href="#local-6989586621681101255"><span class="hs-identifier hs-var">add_implic_seeds</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101260"><span class="hs-identifier hs-var">old_needs</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101261"><span class="hs-identifier hs-var">implics</span></a></span><span>
</span><span id="line-1966"></span><span>            </span><span id="local-6989586621681101254"><span class="annot"><span class="annottext">seeds2 :: VarSet
</span><a href="#local-6989586621681101254"><span class="hs-identifier hs-var hs-var">seeds2</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(EvBind -&gt; VarSet -&gt; VarSet) -&gt; VarSet -&gt; EvBindMap -&gt; VarSet
forall a. (EvBind -&gt; a -&gt; a) -&gt; a -&gt; EvBindMap -&gt; a
</span><a href="GHC.Tc.Types.Evidence.html#nonDetStrictFoldEvBindMap"><span class="hs-identifier hs-var">nonDetStrictFoldEvBindMap</span></a></span><span> </span><span class="annot"><span class="annottext">EvBind -&gt; VarSet -&gt; VarSet
</span><a href="#local-6989586621681101252"><span class="hs-identifier hs-var">add_wanted</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101256"><span class="hs-identifier hs-var">seeds1</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101259"><span class="hs-identifier hs-var">ev_binds</span></a></span><span>
</span><span id="line-1967"></span><span>                            </span><span class="hs-comment">-- It's OK to use a non-deterministic fold here</span><span>
</span><span id="line-1968"></span><span>                            </span><span class="hs-comment">-- because add_wanted is commutative</span><span>
</span><span id="line-1969"></span><span>            </span><span id="local-6989586621681101251"><span class="annot"><span class="annottext">seeds3 :: VarSet
</span><a href="#local-6989586621681101251"><span class="hs-identifier hs-var hs-var">seeds3</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101254"><span class="hs-identifier hs-var">seeds2</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101258"><span class="hs-identifier hs-var">tcvs</span></a></span><span>
</span><span id="line-1970"></span><span>            </span><span id="local-6989586621681101250"><span class="annot"><span class="annottext">need_inner :: VarSet
</span><a href="#local-6989586621681101250"><span class="hs-identifier hs-var hs-var">need_inner</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EvBindMap -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Tc.Types.Evidence.html#findNeededEvVars"><span class="hs-identifier hs-var">findNeededEvVars</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101259"><span class="hs-identifier hs-var">ev_binds</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101251"><span class="hs-identifier hs-var">seeds3</span></a></span><span>
</span><span id="line-1971"></span><span>            </span><span id="local-6989586621681101248"><span class="annot"><span class="annottext">live_ev_binds :: EvBindMap
</span><a href="#local-6989586621681101248"><span class="hs-identifier hs-var hs-var">live_ev_binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(EvBind -&gt; Bool) -&gt; EvBindMap -&gt; EvBindMap
</span><a href="GHC.Tc.Types.Evidence.html#filterEvBindMap"><span class="hs-identifier hs-var">filterEvBindMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; EvBind -&gt; Bool
</span><a href="#local-6989586621681101246"><span class="hs-identifier hs-var">needed_ev_bind</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101250"><span class="hs-identifier hs-var">need_inner</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101259"><span class="hs-identifier hs-var">ev_binds</span></a></span><span>
</span><span id="line-1972"></span><span>            </span><span id="local-6989586621681101245"><span class="annot"><span class="annottext">need_outer :: VarSet
</span><a href="#local-6989586621681101245"><span class="hs-identifier hs-var hs-var">need_outer</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; EvBindMap -&gt; VarSet
</span><a href="GHC.Tc.Types.Evidence.html#varSetMinusEvBindMap"><span class="hs-identifier hs-var">varSetMinusEvBindMap</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101250"><span class="hs-identifier hs-var">need_inner</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101248"><span class="hs-identifier hs-var">live_ev_binds</span></a></span><span>
</span><span id="line-1973"></span><span>                            </span><span class="annot"><span class="annottext">VarSet -&gt; [TcTyVar] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#delVarSetList"><span class="hs-operator hs-var">`delVarSetList`</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101263"><span class="hs-identifier hs-var">givens</span></a></span><span>
</span><span id="line-1974"></span><span>
</span><span id="line-1975"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; EvBindMap -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#setTcEvBindsMap"><span class="hs-identifier hs-var">TcS.setTcEvBindsMap</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101262"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101248"><span class="hs-identifier hs-var">live_ev_binds</span></a></span><span>
</span><span id="line-1976"></span><span>           </span><span class="hs-comment">-- See Note [Delete dead Given evidence bindings]</span><span>
</span><span id="line-1977"></span><span>
</span><span id="line-1978"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;neededEvVars&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcS ()) -&gt; SDoc -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1979"></span><span>        </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;old_needs:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101260"><span class="hs-identifier hs-var">old_needs</span></a></span><span>
</span><span id="line-1980"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;seeds3:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101251"><span class="hs-identifier hs-var">seeds3</span></a></span><span>
</span><span id="line-1981"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcvs:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101258"><span class="hs-identifier hs-var">tcvs</span></a></span><span>
</span><span id="line-1982"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ev_binds:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindMap -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101259"><span class="hs-identifier hs-var">ev_binds</span></a></span><span>
</span><span id="line-1983"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;live_ev_binds:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindMap -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101248"><span class="hs-identifier hs-var">live_ev_binds</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1984"></span><span>
</span><span id="line-1985"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Implication -&gt; TcS Implication
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101264"><span class="hs-identifier hs-var">implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_need_inner :: VarSet
</span><a href="GHC.Tc.Types.Constraint.html#ic_need_inner"><span class="hs-identifier hs-var">ic_need_inner</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101250"><span class="hs-identifier hs-var">need_inner</span></a></span><span>
</span><span id="line-1986"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_need_outer :: VarSet
</span><a href="GHC.Tc.Types.Constraint.html#ic_need_outer"><span class="hs-identifier hs-var">ic_need_outer</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101245"><span class="hs-identifier hs-var">need_outer</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1987"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1988"></span><span>   </span><span id="local-6989586621681101255"><span class="annot"><span class="annottext">add_implic_seeds :: Implication -&gt; VarSet -&gt; VarSet
</span><a href="#local-6989586621681101255"><span class="hs-identifier hs-var hs-var">add_implic_seeds</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implic"><span class="hs-identifier hs-type">Implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_need_outer :: Implication -&gt; VarSet
</span><a href="GHC.Tc.Types.Constraint.html#ic_need_outer"><span class="hs-identifier hs-var">ic_need_outer</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101242"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101242"><span class="hs-identifier hs-var">needs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681101241"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101241"><span class="hs-identifier hs-var">acc</span></a></span></span><span>
</span><span id="line-1989"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101242"><span class="hs-identifier hs-var">needs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101241"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-1990"></span><span>
</span><span id="line-1991"></span><span>   </span><span id="local-6989586621681101246"><span class="annot"><span class="annottext">needed_ev_bind :: VarSet -&gt; EvBind -&gt; Bool
</span><a href="#local-6989586621681101246"><span class="hs-identifier hs-var hs-var">needed_ev_bind</span></a></span></span><span> </span><span id="local-6989586621681101240"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101240"><span class="hs-identifier hs-var">needed</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#EvBind"><span class="hs-identifier hs-type">EvBind</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">eb_lhs :: EvBind -&gt; TcTyVar
</span><a href="GHC.Tc.Types.Evidence.html#eb_lhs"><span class="hs-identifier hs-var">eb_lhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101237"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101237"><span class="hs-identifier hs-var">ev_var</span></a></span></span><span>
</span><span id="line-1992"></span><span>                                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">eb_is_given :: EvBind -&gt; Bool
</span><a href="GHC.Tc.Types.Evidence.html#eb_is_given"><span class="hs-identifier hs-var">eb_is_given</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101235"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101235"><span class="hs-identifier hs-var">is_given</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1993"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101235"><span class="hs-identifier hs-var">is_given</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101237"><span class="hs-identifier hs-var">ev_var</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101240"><span class="hs-identifier hs-var">needed</span></a></span><span>
</span><span id="line-1994"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>   </span><span class="hs-comment">-- Keep all wanted bindings</span><span>
</span><span id="line-1995"></span><span>
</span><span id="line-1996"></span><span>   </span><span class="annot"><a href="#local-6989586621681101252"><span class="hs-identifier hs-type">add_wanted</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#EvBind"><span class="hs-identifier hs-type">EvBind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-1997"></span><span>   </span><span id="local-6989586621681101252"><span class="annot"><span class="annottext">add_wanted :: EvBind -&gt; VarSet -&gt; VarSet
</span><a href="#local-6989586621681101252"><span class="hs-identifier hs-var hs-var">add_wanted</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#EvBind"><span class="hs-identifier hs-type">EvBind</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">eb_is_given :: EvBind -&gt; Bool
</span><a href="GHC.Tc.Types.Evidence.html#eb_is_given"><span class="hs-identifier hs-var">eb_is_given</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101234"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101234"><span class="hs-identifier hs-var">is_given</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">eb_rhs :: EvBind -&gt; EvTerm
</span><a href="GHC.Tc.Types.Evidence.html#eb_rhs"><span class="hs-identifier hs-var">eb_rhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101232"><span class="annot"><span class="annottext">EvTerm
</span><a href="#local-6989586621681101232"><span class="hs-identifier hs-var">rhs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681101231"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101231"><span class="hs-identifier hs-var">needs</span></a></span></span><span>
</span><span id="line-1998"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101234"><span class="hs-identifier hs-var">is_given</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101231"><span class="hs-identifier hs-var">needs</span></a></span><span>  </span><span class="hs-comment">-- Add the rhs vars of the Wanted bindings only</span><span>
</span><span id="line-1999"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EvTerm -&gt; VarSet
</span><a href="GHC.Tc.Types.Evidence.html#evVarsOfTerm"><span class="hs-identifier hs-var">evVarsOfTerm</span></a></span><span> </span><span class="annot"><span class="annottext">EvTerm
</span><a href="#local-6989586621681101232"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101231"><span class="hs-identifier hs-var">needs</span></a></span><span>
</span><span id="line-2000"></span><span>
</span><span id="line-2001"></span><span class="hs-comment">-------------------------------------------------</span><span>
</span><span id="line-2002"></span><span class="annot"><a href="GHC.Tc.Solver.html#simplifyHoles"><span class="hs-identifier hs-type">simplifyHoles</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2003"></span><span id="simplifyHoles"><span class="annot"><span class="annottext">simplifyHoles :: Bag Hole -&gt; TcS (Bag Hole)
</span><a href="GHC.Tc.Solver.html#simplifyHoles"><span class="hs-identifier hs-var hs-var">simplifyHoles</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Hole -&gt; TcS Hole) -&gt; Bag Hole -&gt; TcS (Bag Hole)
forall (m :: * -&gt; *) a b.
Monad m =&gt;
(a -&gt; m b) -&gt; Bag a -&gt; m (Bag b)
</span><a href="GHC.Data.Bag.html#mapBagM"><span class="hs-identifier hs-var">mapBagM</span></a></span><span> </span><span class="annot"><span class="annottext">Hole -&gt; TcS Hole
</span><a href="#local-6989586621681101229"><span class="hs-identifier hs-var">simpl_hole</span></a></span><span>
</span><span id="line-2004"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2005"></span><span>    </span><span class="annot"><a href="#local-6989586621681101229"><span class="hs-identifier hs-type">simpl_hole</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span>
</span><span id="line-2006"></span><span>    </span><span id="local-6989586621681101229"><span class="annot"><span class="annottext">simpl_hole :: Hole -&gt; TcS Hole
</span><a href="#local-6989586621681101229"><span class="hs-identifier hs-var hs-var">simpl_hole</span></a></span></span><span> </span><span id="local-6989586621681101228"><span class="annot"><span class="annottext">h :: Hole
</span><a href="#local-6989586621681101228"><span class="hs-identifier hs-var">h</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">hole_ty :: Hole -&gt; Type
</span><a href="GHC.Tc.Types.Constraint.html#hole_ty"><span class="hs-identifier hs-var">hole_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101225"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101225"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hole_loc :: Hole -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#hole_loc"><span class="hs-identifier hs-var">hole_loc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101223"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681101223"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2007"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101222"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101222"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtLoc -&gt; Type -&gt; TcS Type
</span><a href="GHC.Tc.Solver.Flatten.html#flattenType"><span class="hs-identifier hs-var">flattenType</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681101223"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101225"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2008"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Hole -&gt; TcS Hole
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Hole
</span><a href="#local-6989586621681101228"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">hole_ty :: Type
</span><a href="GHC.Tc.Types.Constraint.html#hole_ty"><span class="hs-identifier hs-var">hole_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101222"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2009"></span><span>
</span><span id="line-2010"></span><span class="hs-comment">{- Note [Delete dead Given evidence bindings]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As a result of superclass expansion, we speculatively
generate evidence bindings for Givens. E.g.
   f :: (a ~ b) =&gt; a -&gt; b -&gt; Bool
   f x y = ...
We'll have
   [G] d1 :: (a~b)
and we'll speculatively generate the evidence binding
   [G] d2 :: (a ~# b) = sc_sel d

Now d2 is available for solving.  But it may not be needed!  Usually
such dead superclass selections will eventually be dropped as dead
code, but:

 * It won't always be dropped (#13032).  In the case of an
   unlifted-equality superclass like d2 above, we generate
       case heq_sc d1 of d2 -&gt; ...
   and we can't (in general) drop that case expression in case
   d1 is bottom.  So it's technically unsound to have added it
   in the first place.

 * Simply generating all those extra superclasses can generate lots of
   code that has to be zonked, only to be discarded later.  Better not
   to generate it in the first place.

   Moreover, if we simplify this implication more than once
   (e.g. because we can't solve it completely on the first iteration
   of simpl_looop), we'll generate all the same bindings AGAIN!

Easy solution: take advantage of the work we are doing to track dead
(unused) Givens, and use it to prune the Given bindings too.  This is
all done by neededEvVars.

This led to a remarkable 25% overall compiler allocation decrease in
test T12227.

But we don't get to discard all redundant equality superclasses, alas;
see #15205.

Note [Tracking redundant constraints]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
With Opt_WarnRedundantConstraints, GHC can report which
constraints of a type signature (or instance declaration) are
redundant, and can be omitted.  Here is an overview of how it
works:

----- What is a redundant constraint?

* The things that can be redundant are precisely the Given
  constraints of an implication.

* A constraint can be redundant in two different ways:
  a) It is implied by other givens.  E.g.
       f :: (Eq a, Ord a)     =&gt; blah   -- Eq a unnecessary
       g :: (Eq a, a~b, Eq b) =&gt; blah   -- Either Eq a or Eq b unnecessary
  b) It is not needed by the Wanted constraints covered by the
     implication E.g.
       f :: Eq a =&gt; a -&gt; Bool
       f x = True  -- Equality not used

*  To find (a), when we have two Given constraints,
   we must be careful to drop the one that is a naked variable (if poss).
   So if we have
       f :: (Eq a, Ord a) =&gt; blah
   then we may find [G] sc_sel (d1::Ord a) :: Eq a
                    [G] d2 :: Eq a
   We want to discard d2 in favour of the superclass selection from
   the Ord dictionary.  This is done by GHC.Tc.Solver.Interact.solveOneFromTheOther
   See Note [Replacement vs keeping].

* To find (b) we need to know which evidence bindings are 'wanted';
  hence the eb_is_given field on an EvBind.

----- How tracking works

* The ic_need fields of an Implic records in-scope (given) evidence
  variables bound by the context, that were needed to solve this
  implication (so far).  See the declaration of Implication.

* When the constraint solver finishes solving all the wanteds in
  an implication, it sets its status to IC_Solved

  - The ics_dead field, of IC_Solved, records the subset of this
    implication's ic_given that are redundant (not needed).

* We compute which evidence variables are needed by an implication
  in setImplicationStatus.  A variable is needed if
    a) it is free in the RHS of a Wanted EvBind,
    b) it is free in the RHS of an EvBind whose LHS is needed,
    c) it is in the ics_need of a nested implication.

* We need to be careful not to discard an implication
  prematurely, even one that is fully solved, because we might
  thereby forget which variables it needs, and hence wrongly
  report a constraint as redundant.  But we can discard it once
  its free vars have been incorporated into its parent; or if it
  simply has no free vars. This careful discarding is also
  handled in setImplicationStatus.

----- Reporting redundant constraints

* GHC.Tc.Errors does the actual warning, in warnRedundantConstraints.

* We don't report redundant givens for *every* implication; only
  for those which reply True to GHC.Tc.Solver.warnRedundantGivens:

   - For example, in a class declaration, the default method *can*
     use the class constraint, but it certainly doesn't *have* to,
     and we don't want to report an error there.

   - More subtly, in a function definition
       f :: (Ord a, Ord a, Ix a) =&gt; a -&gt; a
       f x = rhs
     we do an ambiguity check on the type (which would find that one
     of the Ord a constraints was redundant), and then we check that
     the definition has that type (which might find that both are
     redundant).  We don't want to report the same error twice, so we
     disable it for the ambiguity check.  Hence using two different
     FunSigCtxts, one with the warn-redundant field set True, and the
     other set False in
        - GHC.Tc.Gen.Bind.tcSpecPrag
        - GHC.Tc.Gen.Bind.tcTySig

  This decision is taken in setImplicationStatus, rather than GHC.Tc.Errors
  so that we can discard implication constraints that we don't need.
  So ics_dead consists only of the *reportable* redundant givens.

----- Shortcomings

Consider (see #9939)
    f2 :: (Eq a, Ord a) =&gt; a -&gt; a -&gt; Bool
    -- Ord a redundant, but Eq a is reported
    f2 x y = (x == y)

We report (Eq a) as redundant, whereas actually (Ord a) is.  But it's
really not easy to detect that!


Note [Cutting off simpl_loop]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It is very important not to iterate in simpl_loop unless there is a chance
of progress.  #8474 is a classic example:

  * There's a deeply-nested chain of implication constraints.
       ?x:alpha =&gt; ?y1:beta1 =&gt; ... ?yn:betan =&gt; [W] ?x:Int

  * From the innermost one we get a [D] alpha ~ Int,
    but alpha is untouchable until we get out to the outermost one

  * We float [D] alpha~Int out (it is in floated_eqs), but since alpha
    is untouchable, the solveInteract in simpl_loop makes no progress

  * So there is no point in attempting to re-solve
       ?yn:betan =&gt; [W] ?x:Int
    via solveNestedImplications, because we'll just get the
    same [D] again

  * If we *do* re-solve, we'll get an infinite loop. It is cut off by
    the fixed bound of 10, but solving the next takes 10*10*...*10 (ie
    exponentially many) iterations!

Conclusion: we should call solveNestedImplications only if we did
some unification in solveSimpleWanteds; because that's the only way
we'll get more Givens (a unification is like adding a Given) to
allow the implication to make progress.
-}</span><span>
</span><span id="line-2177"></span><span>
</span><span id="line-2178"></span><span class="annot"><a href="GHC.Tc.Solver.html#promoteTyVarTcS"><span class="hs-identifier hs-type">promoteTyVarTcS</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-2179"></span><span class="hs-comment">-- When we float a constraint out of an implication we must restore</span><span>
</span><span id="line-2180"></span><span class="hs-comment">-- invariant (WantedInv) in Note [TcLevel and untouchable type variables] in GHC.Tc.Utils.TcType</span><span>
</span><span id="line-2181"></span><span class="hs-comment">-- See Note [Promoting unification variables]</span><span>
</span><span id="line-2182"></span><span class="hs-comment">-- We don't just call promoteTyVar because we want to use unifyTyVar,</span><span>
</span><span id="line-2183"></span><span class="hs-comment">-- not writeMetaTyVar</span><span>
</span><span id="line-2184"></span><span id="promoteTyVarTcS"><span class="annot"><span class="annottext">promoteTyVarTcS :: TcTyVar -&gt; TcS ()
</span><a href="GHC.Tc.Solver.html#promoteTyVarTcS"><span class="hs-identifier hs-var hs-var">promoteTyVarTcS</span></a></span></span><span> </span><span id="local-6989586621681101220"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101220"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-2185"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101219"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101219"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS TcLevel
</span><a href="GHC.Tc.Solver.Monad.html#getTcLevel"><span class="hs-identifier hs-var">TcS.getTcLevel</span></a></span><span>
</span><span id="line-2186"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcS () -&gt; TcS ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcLevel -&gt; TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isFloatedTouchableMetaTyVar"><span class="hs-identifier hs-var">isFloatedTouchableMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101219"><span class="hs-identifier hs-var">tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101220"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcS () -&gt; TcS ()) -&gt; TcS () -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-2187"></span><span>         </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101217"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101217"><span class="hs-identifier hs-var">cloned_tv</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcS TcTyVar
</span><a href="GHC.Tc.Solver.Monad.html#cloneMetaTyVar"><span class="hs-identifier hs-var">TcS.cloneMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101220"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2188"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101215"><span class="annot"><span class="annottext">rhs_tv :: TcTyVar
</span><a href="#local-6989586621681101215"><span class="hs-identifier hs-var hs-var">rhs_tv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcLevel -&gt; TcTyVar
</span><a href="GHC.Tc.Utils.TcType.html#setMetaTyVarTcLevel"><span class="hs-identifier hs-var">setMetaTyVarTcLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101217"><span class="hs-identifier hs-var">cloned_tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101219"><span class="hs-identifier hs-var">tclvl</span></a></span><span>
</span><span id="line-2189"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Type -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#unifyTyVar"><span class="hs-identifier hs-var">unifyTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101220"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101215"><span class="hs-identifier hs-var">rhs_tv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2190"></span><span>
</span><span id="line-2191"></span><span class="hs-comment">-- | Like 'defaultTyVar', but in the TcS monad.</span><span>
</span><span id="line-2192"></span><span class="annot"><a href="GHC.Tc.Solver.html#defaultTyVarTcS"><span class="hs-identifier hs-type">defaultTyVarTcS</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2193"></span><span id="defaultTyVarTcS"><span class="annot"><span class="annottext">defaultTyVarTcS :: TcTyVar -&gt; TcS Bool
</span><a href="GHC.Tc.Solver.html#defaultTyVarTcS"><span class="hs-identifier hs-var hs-var">defaultTyVarTcS</span></a></span></span><span> </span><span id="local-6989586621681101212"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101212"><span class="hs-identifier hs-var">the_tv</span></a></span></span><span>
</span><span id="line-2194"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Core.Type.html#isRuntimeRepVar"><span class="hs-identifier hs-var">isRuntimeRepVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101212"><span class="hs-identifier hs-var">the_tv</span></a></span><span>
</span><span id="line-2195"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isTyVarTyVar"><span class="hs-identifier hs-var">isTyVarTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101212"><span class="hs-identifier hs-var">the_tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2196"></span><span>    </span><span class="hs-comment">-- TyVarTvs should only be unified with a tyvar</span><span>
</span><span id="line-2197"></span><span>    </span><span class="hs-comment">-- never with a type; c.f. GHC.Tc.Utils.TcMType.defaultTyVar</span><span>
</span><span id="line-2198"></span><span>    </span><span class="hs-comment">-- and Note [Inferring kinds for type declarations] in GHC.Tc.TyCl</span><span>
</span><span id="line-2199"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;defaultTyVarTcS RuntimeRep&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101212"><span class="hs-identifier hs-var">the_tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2200"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Type -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#unifyTyVar"><span class="hs-identifier hs-var">unifyTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101212"><span class="hs-identifier hs-var">the_tv</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#liftedRepTy"><span class="hs-identifier hs-var">liftedRepTy</span></a></span><span>
</span><span id="line-2201"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcS Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2202"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Core.Type.html#isMultiplicityVar"><span class="hs-identifier hs-var">isMultiplicityVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101212"><span class="hs-identifier hs-var">the_tv</span></a></span><span>
</span><span id="line-2203"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isTyVarTyVar"><span class="hs-identifier hs-var">isTyVarTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101212"><span class="hs-identifier hs-var">the_tv</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- TyVarTvs should only be unified with a tyvar</span><span>
</span><span id="line-2204"></span><span>                             </span><span class="hs-comment">-- never with a type; c.f. TcMType.defaultTyVar</span><span>
</span><span id="line-2205"></span><span>                             </span><span class="hs-comment">-- See Note [Kind generalisation and SigTvs]</span><span>
</span><span id="line-2206"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;defaultTyVarTcS Multiplicity&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101212"><span class="hs-identifier hs-var">the_tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2207"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Type -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#unifyTyVar"><span class="hs-identifier hs-var">unifyTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101212"><span class="hs-identifier hs-var">the_tv</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#manyDataConTy"><span class="hs-identifier hs-var">manyDataConTy</span></a></span><span>
</span><span id="line-2208"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcS Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2209"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2210"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcS Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>  </span><span class="hs-comment">-- the common case</span><span>
</span><span id="line-2211"></span><span>
</span><span id="line-2212"></span><span class="annot"><a href="GHC.Tc.Solver.html#approximateWC"><span class="hs-identifier hs-type">approximateWC</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Cts"><span class="hs-identifier hs-type">Cts</span></a></span><span>
</span><span id="line-2213"></span><span class="hs-comment">-- Postcondition: Wanted or Derived Cts</span><span>
</span><span id="line-2214"></span><span class="hs-comment">-- See Note [ApproximateWC]</span><span>
</span><span id="line-2215"></span><span id="approximateWC"><span class="annot"><span class="annottext">approximateWC :: Bool -&gt; WantedConstraints -&gt; Cts
</span><a href="GHC.Tc.Solver.html#approximateWC"><span class="hs-identifier hs-var hs-var">approximateWC</span></a></span></span><span> </span><span id="local-6989586621681101208"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101208"><span class="hs-identifier hs-var">float_past_equalities</span></a></span></span><span> </span><span id="local-6989586621681101207"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101207"><span class="hs-identifier hs-var">wc</span></a></span></span><span>
</span><span id="line-2216"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; WantedConstraints -&gt; Cts
</span><a href="#local-6989586621681101206"><span class="hs-identifier hs-var">float_wc</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101207"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-2217"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2218"></span><span>    </span><span class="annot"><a href="#local-6989586621681101206"><span class="hs-identifier hs-type">float_wc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyCoVarSet"><span class="hs-identifier hs-type">TcTyCoVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Cts"><span class="hs-identifier hs-type">Cts</span></a></span><span>
</span><span id="line-2219"></span><span>    </span><span id="local-6989586621681101206"><span class="annot"><span class="annottext">float_wc :: VarSet -&gt; WantedConstraints -&gt; Cts
</span><a href="#local-6989586621681101206"><span class="hs-identifier hs-var hs-var">float_wc</span></a></span></span><span> </span><span id="local-6989586621681101205"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101205"><span class="hs-identifier hs-var">trapping_tvs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WC"><span class="hs-identifier hs-type">WC</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: WantedConstraints -&gt; Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101204"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101204"><span class="hs-identifier hs-var">simples</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_impl :: WantedConstraints -&gt; Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101203"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101203"><span class="hs-identifier hs-var">implics</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2220"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; Bool) -&gt; Cts -&gt; Cts
forall a. (a -&gt; Bool) -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#filterBag"><span class="hs-identifier hs-var">filterBag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; Ct -&gt; Bool
</span><a href="#local-6989586621681101202"><span class="hs-identifier hs-var">is_floatable</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101205"><span class="hs-identifier hs-var">trapping_tvs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101204"><span class="hs-identifier hs-var">simples</span></a></span><span> </span><span class="annot"><span class="annottext">Cts -&gt; Cts -&gt; Cts
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span>
</span><span id="line-2221"></span><span>        </span><span class="annot"><span class="annottext">(Implication -&gt; Cts) -&gt; Bag Implication -&gt; Cts
forall a b. (a -&gt; Bag b) -&gt; Bag a -&gt; Bag b
</span><a href="GHC.Data.Bag.html#concatMapBag"><span class="hs-identifier hs-var">concatMapBag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; Implication -&gt; Cts
</span><a href="#local-6989586621681101200"><span class="hs-identifier hs-var">float_implic</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101205"><span class="hs-identifier hs-var">trapping_tvs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681101203"><span class="hs-identifier hs-var">implics</span></a></span><span>
</span><span id="line-2222"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-2223"></span><span>
</span><span id="line-2224"></span><span>    </span><span class="annot"><a href="#local-6989586621681101200"><span class="hs-identifier hs-type">float_implic</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyCoVarSet"><span class="hs-identifier hs-type">TcTyCoVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Cts"><span class="hs-identifier hs-type">Cts</span></a></span><span>
</span><span id="line-2225"></span><span>    </span><span id="local-6989586621681101200"><span class="annot"><span class="annottext">float_implic :: VarSet -&gt; Implication -&gt; Cts
</span><a href="#local-6989586621681101200"><span class="hs-identifier hs-var hs-var">float_implic</span></a></span></span><span> </span><span id="local-6989586621681101199"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101199"><span class="hs-identifier hs-var">trapping_tvs</span></a></span></span><span> </span><span id="local-6989586621681101198"><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101198"><span class="hs-identifier hs-var">imp</span></a></span></span><span>
</span><span id="line-2226"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101208"><span class="hs-identifier hs-var">float_past_equalities</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Implication -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#ic_no_eqs"><span class="hs-identifier hs-var hs-var">ic_no_eqs</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101198"><span class="hs-identifier hs-var">imp</span></a></span><span>
</span><span id="line-2227"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; WantedConstraints -&gt; Cts
</span><a href="#local-6989586621681101206"><span class="hs-identifier hs-var">float_wc</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101197"><span class="hs-identifier hs-var">new_trapping_tvs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var hs-var">ic_wanted</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101198"><span class="hs-identifier hs-var">imp</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2228"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-comment">-- Take care with equalities</span><span>
</span><span id="line-2229"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="GHC.Tc.Types.Constraint.html#emptyCts"><span class="hs-identifier hs-var">emptyCts</span></a></span><span>    </span><span class="hs-comment">-- See (1) under Note [ApproximateWC]</span><span>
</span><span id="line-2230"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-2231"></span><span>        </span><span id="local-6989586621681101197"><span class="annot"><span class="annottext">new_trapping_tvs :: VarSet
</span><a href="#local-6989586621681101197"><span class="hs-identifier hs-var hs-var">new_trapping_tvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101199"><span class="hs-identifier hs-var">trapping_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; [TcTyVar] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSetList"><span class="hs-operator hs-var">`extendVarSetList`</span></a></span><span> </span><span class="annot"><span class="annottext">Implication -&gt; [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_skols"><span class="hs-identifier hs-var hs-var">ic_skols</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681101198"><span class="hs-identifier hs-var">imp</span></a></span><span>
</span><span id="line-2232"></span><span>
</span><span id="line-2233"></span><span>    </span><span id="local-6989586621681101202"><span class="annot"><span class="annottext">is_floatable :: VarSet -&gt; Ct -&gt; Bool
</span><a href="#local-6989586621681101202"><span class="hs-identifier hs-var hs-var">is_floatable</span></a></span></span><span> </span><span id="local-6989586621681101196"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101196"><span class="hs-identifier hs-var">skol_tvs</span></a></span></span><span> </span><span id="local-6989586621681101195"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101195"><span class="hs-identifier hs-var">ct</span></a></span></span><span>
</span><span id="line-2234"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isGivenCt"><span class="hs-identifier hs-var">isGivenCt</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101195"><span class="hs-identifier hs-var">ct</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2235"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#insolubleEqCt"><span class="hs-identifier hs-var">insolubleEqCt</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101195"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2236"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; VarSet
</span><a href="GHC.Tc.Types.Constraint.html#tyCoVarsOfCt"><span class="hs-identifier hs-var">tyCoVarsOfCt</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101195"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#disjointVarSet"><span class="hs-operator hs-var">`disjointVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101196"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span>
</span><span id="line-2237"></span><span>
</span><span id="line-2238"></span><span class="hs-comment">{- Note [ApproximateWC]
~~~~~~~~~~~~~~~~~~~~~~~
approximateWC takes a constraint, typically arising from the RHS of a
let-binding whose type we are *inferring*, and extracts from it some
*simple* constraints that we might plausibly abstract over.  Of course
the top-level simple constraints are plausible, but we also float constraints
out from inside, if they are not captured by skolems.

The same function is used when doing type-class defaulting (see the call
to applyDefaultingRules) to extract constraints that might be defaulted.

There is one caveat:

1.  When inferring most-general types (in simplifyInfer), we do *not*
    float anything out if the implication binds equality constraints,
    because that defeats the OutsideIn story.  Consider
       data T a where
         TInt :: T Int
         MkT :: T a

       f TInt = 3::Int

    We get the implication (a ~ Int =&gt; res ~ Int), where so far we've decided
      f :: T a -&gt; res
    We don't want to float (res~Int) out because then we'll infer
      f :: T a -&gt; Int
    which is only on of the possible types. (GHC 7.6 accidentally *did*
    float out of such implications, which meant it would happily infer
    non-principal types.)

   HOWEVER (#12797) in findDefaultableGroups we are not worried about
   the most-general type; and we /do/ want to float out of equalities.
   Hence the boolean flag to approximateWC.

------ Historical note -----------
There used to be a second caveat, driven by #8155

   2. We do not float out an inner constraint that shares a type variable
      (transitively) with one that is trapped by a skolem.  Eg
          forall a.  F a ~ beta, Integral beta
      We don't want to float out (Integral beta).  Doing so would be bad
      when defaulting, because then we'll default beta:=Integer, and that
      makes the error message much worse; we'd get
          Can't solve  F a ~ Integer
      rather than
          Can't solve  Integral (F a)

      Moreover, floating out these &quot;contaminated&quot; constraints doesn't help
      when generalising either. If we generalise over (Integral b), we still
      can't solve the retained implication (forall a. F a ~ b).  Indeed,
      arguably that too would be a harder error to understand.

But this transitive closure stuff gives rise to a complex rule for
when defaulting actually happens, and one that was never documented.
Moreover (#12923), the more complex rule is sometimes NOT what
you want.  So I simply removed the extra code to implement the
contamination stuff.  There was zero effect on the testsuite (not even
#8155).
------ End of historical note -----------


Note [DefaultTyVar]
~~~~~~~~~~~~~~~~~~~
defaultTyVar is used on any un-instantiated meta type variables to
default any RuntimeRep variables to LiftedRep.  This is important
to ensure that instance declarations match.  For example consider

     instance Show (a-&gt;b)
     foo x = show (\_ -&gt; True)

Then we'll get a constraint (Show (p -&gt;q)) where p has kind (TYPE r),
and that won't match the tcTypeKind (*) in the instance decl.  See tests
tc217 and tc175.

We look only at touchable type variables. No further constraints
are going to affect these type variables, so it's time to do it by
hand.  However we aren't ready to default them fully to () or
whatever, because the type-class defaulting rules have yet to run.

An alternate implementation would be to emit a derived constraint setting
the RuntimeRep variable to LiftedRep, but this seems unnecessarily indirect.

Note [Promote _and_ default when inferring]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we are inferring a type, we simplify the constraint, and then use
approximateWC to produce a list of candidate constraints.  Then we MUST

  a) Promote any meta-tyvars that have been floated out by
     approximateWC, to restore invariant (WantedInv) described in
     Note [TcLevel and untouchable type variables] in GHC.Tc.Utils.TcType.

  b) Default the kind of any meta-tyvars that are not mentioned in
     in the environment.

To see (b), suppose the constraint is (C ((a :: OpenKind) -&gt; Int)), and we
have an instance (C ((x:*) -&gt; Int)).  The instance doesn't match -- but it
should!  If we don't solve the constraint, we'll stupidly quantify over
(C (a-&gt;Int)) and, worse, in doing so skolemiseQuantifiedTyVar will quantify over
(b:*) instead of (a:OpenKind), which can lead to disaster; see #7332.
#7641 is a simpler example.

Note [Promoting unification variables]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we float an equality out of an implication we must &quot;promote&quot; free
unification variables of the equality, in order to maintain Invariant
(WantedInv) from Note [TcLevel and untouchable type variables] in
TcType.  for the leftover implication.

This is absolutely necessary. Consider the following example. We start
with two implications and a class with a functional dependency.

    class C x y | x -&gt; y
    instance C [a] [a]

    (I1)      [untch=beta]forall b. 0 =&gt; F Int ~ [beta]
    (I2)      [untch=beta]forall c. 0 =&gt; F Int ~ [[alpha]] /\ C beta [c]

We float (F Int ~ [beta]) out of I1, and we float (F Int ~ [[alpha]]) out of I2.
They may react to yield that (beta := [alpha]) which can then be pushed inwards
the leftover of I2 to get (C [alpha] [a]) which, using the FunDep, will mean that
(alpha := a). In the end we will have the skolem 'b' escaping in the untouchable
beta! Concrete example is in indexed_types/should_fail/ExtraTcsUntch.hs:

    class C x y | x -&gt; y where
     op :: x -&gt; y -&gt; ()

    instance C [a] [a]

    type family F a :: *

    h :: F Int -&gt; ()
    h = undefined

    data TEx where
      TEx :: a -&gt; TEx

    f (x::beta) =
        let g1 :: forall b. b -&gt; ()
            g1 _ = h [x]
            g2 z = case z of TEx y -&gt; (h [[undefined]], op x [y])
        in (g1 '3', g2 undefined)



*********************************************************************************
*                                                                               *
*                          Floating equalities                                  *
*                                                                               *
*********************************************************************************

Note [Float Equalities out of Implications]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For ordinary pattern matches (including existentials) we float
equalities out of implications, for instance:
     data T where
       MkT :: Eq a =&gt; a -&gt; T
     f x y = case x of MkT _ -&gt; (y::Int)
We get the implication constraint (x::T) (y::alpha):
     forall a. [untouchable=alpha] Eq a =&gt; alpha ~ Int
We want to float out the equality into a scope where alpha is no
longer untouchable, to solve the implication!

But we cannot float equalities out of implications whose givens may
yield or contain equalities:

      data T a where
        T1 :: T Int
        T2 :: T Bool
        T3 :: T a

      h :: T a -&gt; a -&gt; Int

      f x y = case x of
                T1 -&gt; y::Int
                T2 -&gt; y::Bool
                T3 -&gt; h x y

We generate constraint, for (x::T alpha) and (y :: beta):
   [untouchables = beta] (alpha ~ Int =&gt; beta ~ Int)   -- From 1st branch
   [untouchables = beta] (alpha ~ Bool =&gt; beta ~ Bool) -- From 2nd branch
   (alpha ~ beta)                                      -- From 3rd branch

If we float the equality (beta ~ Int) outside of the first implication and
the equality (beta ~ Bool) out of the second we get an insoluble constraint.
But if we just leave them inside the implications, we unify alpha := beta and
solve everything.

Principle:
    We do not want to float equalities out which may
    need the given *evidence* to become soluble.

Consequence: classes with functional dependencies don't matter (since there is
no evidence for a fundep equality), but equality superclasses do matter (since
they carry evidence).
-}</span><span>
</span><span id="line-2433"></span><span>
</span><span id="line-2434"></span><span class="annot"><a href="GHC.Tc.Solver.html#floatEqualities"><span class="hs-identifier hs-type">floatEqualities</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#EvId"><span class="hs-identifier hs-type">EvId</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#EvBindsVar"><span class="hs-identifier hs-type">EvBindsVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2435"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-2436"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Cts"><span class="hs-identifier hs-type">Cts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2437"></span><span class="hs-comment">-- Main idea: see Note [Float Equalities out of Implications]</span><span>
</span><span id="line-2438"></span><span class="hs-comment">--</span><span>
</span><span id="line-2439"></span><span class="hs-comment">-- Precondition: the wc_simple of the incoming WantedConstraints are</span><span>
</span><span id="line-2440"></span><span class="hs-comment">--               fully zonked, so that we can see their free variables</span><span>
</span><span id="line-2441"></span><span class="hs-comment">--</span><span>
</span><span id="line-2442"></span><span class="hs-comment">-- Postcondition: The returned floated constraints (Cts) are only</span><span>
</span><span id="line-2443"></span><span class="hs-comment">--                Wanted or Derived</span><span>
</span><span id="line-2444"></span><span class="hs-comment">--</span><span>
</span><span id="line-2445"></span><span class="hs-comment">-- Also performs some unifications (via promoteTyVar), adding to</span><span>
</span><span id="line-2446"></span><span class="hs-comment">-- monadically-carried ty_binds. These will be used when processing</span><span>
</span><span id="line-2447"></span><span class="hs-comment">-- floated_eqs later</span><span>
</span><span id="line-2448"></span><span class="hs-comment">--</span><span>
</span><span id="line-2449"></span><span class="hs-comment">-- Subtleties: Note [Float equalities from under a skolem binding]</span><span>
</span><span id="line-2450"></span><span class="hs-comment">--             Note [Skolem escape]</span><span>
</span><span id="line-2451"></span><span class="hs-comment">--             Note [What prevents a constraint from floating]</span><span>
</span><span id="line-2452"></span><span id="floatEqualities"><span class="annot"><span class="annottext">floatEqualities :: [TcTyVar]
-&gt; [TcTyVar]
-&gt; EvBindsVar
-&gt; Bool
-&gt; WantedConstraints
-&gt; TcS (Cts, WantedConstraints)
</span><a href="GHC.Tc.Solver.html#floatEqualities"><span class="hs-identifier hs-var hs-var">floatEqualities</span></a></span></span><span> </span><span id="local-6989586621681101192"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101192"><span class="hs-identifier hs-var">skols</span></a></span></span><span> </span><span id="local-6989586621681101191"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101191"><span class="hs-identifier hs-var">given_ids</span></a></span></span><span> </span><span id="local-6989586621681101190"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101190"><span class="hs-identifier hs-var">ev_binds_var</span></a></span></span><span> </span><span id="local-6989586621681101189"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101189"><span class="hs-identifier hs-var">no_given_eqs</span></a></span></span><span>
</span><span id="line-2453"></span><span>                </span><span id="local-6989586621681101188"><span class="annot"><span class="annottext">wanteds :: WantedConstraints
</span><a href="#local-6989586621681101188"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WC"><span class="hs-identifier hs-type">WC</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: WantedConstraints -&gt; Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681101187"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101187"><span class="hs-identifier hs-var">simples</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2454"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101189"><span class="hs-identifier hs-var">no_given_eqs</span></a></span><span>  </span><span class="hs-comment">-- There are some given equalities, so don't float</span><span>
</span><span id="line-2455"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Cts, WantedConstraints) -&gt; TcS (Cts, WantedConstraints)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101188"><span class="hs-identifier hs-var">wanteds</span></a></span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- Note [Float Equalities out of Implications]</span><span>
</span><span id="line-2456"></span><span>
</span><span id="line-2457"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2458"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- First zonk: the inert set (from whence they came) is fully</span><span>
</span><span id="line-2459"></span><span>         </span><span class="hs-comment">-- zonked, but unflattening may have filled in unification</span><span>
</span><span id="line-2460"></span><span>         </span><span class="hs-comment">-- variables, and we /must/ see them.  Otherwise we may float</span><span>
</span><span id="line-2461"></span><span>         </span><span class="hs-comment">-- constraints that mention the skolems!</span><span>
</span><span id="line-2462"></span><span>         </span><span id="local-6989586621681101186"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101186"><span class="hs-identifier hs-var">simples</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Cts -&gt; TcS Cts
</span><a href="GHC.Tc.Solver.Monad.html#zonkSimples"><span class="hs-identifier hs-var">TcS.zonkSimples</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101187"><span class="hs-identifier hs-var">simples</span></a></span><span>
</span><span id="line-2463"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101184"><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101184"><span class="hs-identifier hs-var">binds</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; TcS EvBindMap
</span><a href="GHC.Tc.Solver.Monad.html#getTcEvBindsMap"><span class="hs-identifier hs-var">TcS.getTcEvBindsMap</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101190"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span>
</span><span id="line-2464"></span><span>
</span><span id="line-2465"></span><span>       </span><span class="hs-comment">-- Now we can pick the ones to float</span><span>
</span><span id="line-2466"></span><span>       </span><span class="hs-comment">-- The constraints are un-flattened and de-canonicalised</span><span>
</span><span id="line-2467"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101183"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101183"><span class="hs-identifier hs-var">candidate_eqs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101182"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101182"><span class="hs-identifier hs-var">no_float_cts</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; Bool) -&gt; Cts -&gt; (Cts, Cts)
forall a. (a -&gt; Bool) -&gt; Bag a -&gt; (Bag a, Bag a)
</span><a href="GHC.Data.Bag.html#partitionBag"><span class="hs-identifier hs-var">partitionBag</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Bool
</span><a href="#local-6989586621681101181"><span class="hs-identifier hs-var">is_float_eq_candidate</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101186"><span class="hs-identifier hs-var">simples</span></a></span><span>
</span><span id="line-2468"></span><span>
</span><span id="line-2469"></span><span>             </span><span id="local-6989586621681101179"><span class="annot"><span class="annottext">seed_skols :: VarSet
</span><a href="#local-6989586621681101179"><span class="hs-identifier hs-var hs-var">seed_skols</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mkVarSet"><span class="hs-identifier hs-var">mkVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101192"><span class="hs-identifier hs-var">skols</span></a></span><span>     </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span>
</span><span id="line-2470"></span><span>                          </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mkVarSet"><span class="hs-identifier hs-var">mkVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101191"><span class="hs-identifier hs-var">given_ids</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span>
</span><span id="line-2471"></span><span>                          </span><span class="annot"><span class="annottext">(Ct -&gt; VarSet -&gt; VarSet) -&gt; VarSet -&gt; Cts -&gt; VarSet
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; VarSet -&gt; VarSet
</span><a href="#local-6989586621681101178"><span class="hs-identifier hs-var">add_non_flt_ct</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101182"><span class="hs-identifier hs-var">no_float_cts</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span>
</span><span id="line-2472"></span><span>                          </span><span class="annot"><span class="annottext">EvBindMap -&gt; VarSet
</span><a href="GHC.Tc.Types.Evidence.html#evBindMapToVarSet"><span class="hs-identifier hs-var">evBindMapToVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindMap
</span><a href="#local-6989586621681101184"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-2473"></span><span>             </span><span class="hs-comment">-- seed_skols: See Note [What prevents a constraint from floating] (1,2,3)</span><span>
</span><span id="line-2474"></span><span>             </span><span class="hs-comment">-- Include the EvIds of any non-floating constraints</span><span>
</span><span id="line-2475"></span><span>
</span><span id="line-2476"></span><span>             </span><span id="local-6989586621681101176"><span class="annot"><span class="annottext">extended_skols :: VarSet
</span><a href="#local-6989586621681101176"><span class="hs-identifier hs-var hs-var">extended_skols</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; VarSet) -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#transCloVarSet"><span class="hs-identifier hs-var">transCloVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts -&gt; VarSet -&gt; VarSet
</span><a href="#local-6989586621681101175"><span class="hs-identifier hs-var">add_captured_ev_ids</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101183"><span class="hs-identifier hs-var">candidate_eqs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101179"><span class="hs-identifier hs-var">seed_skols</span></a></span><span>
</span><span id="line-2477"></span><span>                 </span><span class="hs-comment">-- extended_skols contains the EvIds of all the trapped constraints</span><span>
</span><span id="line-2478"></span><span>                 </span><span class="hs-comment">-- See Note [What prevents a constraint from floating] (3)</span><span>
</span><span id="line-2479"></span><span>
</span><span id="line-2480"></span><span>             </span><span class="hs-special">(</span><span id="local-6989586621681101174"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101174"><span class="hs-identifier hs-var">flt_eqs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101173"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101173"><span class="hs-identifier hs-var">no_flt_eqs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; Bool) -&gt; Cts -&gt; (Cts, Cts)
forall a. (a -&gt; Bool) -&gt; Bag a -&gt; (Bag a, Bag a)
</span><a href="GHC.Data.Bag.html#partitionBag"><span class="hs-identifier hs-var">partitionBag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; Ct -&gt; Bool
</span><a href="#local-6989586621681101172"><span class="hs-identifier hs-var">is_floatable</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101176"><span class="hs-identifier hs-var">extended_skols</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2481"></span><span>                                                  </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101183"><span class="hs-identifier hs-var">candidate_eqs</span></a></span><span>
</span><span id="line-2482"></span><span>
</span><span id="line-2483"></span><span>             </span><span id="local-6989586621681101171"><span class="annot"><span class="annottext">remaining_simples :: Cts
</span><a href="#local-6989586621681101171"><span class="hs-identifier hs-var hs-var">remaining_simples</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101182"><span class="hs-identifier hs-var">no_float_cts</span></a></span><span> </span><span class="annot"><span class="annottext">Cts -&gt; Cts -&gt; Cts
</span><a href="GHC.Tc.Types.Constraint.html#andCts"><span class="hs-operator hs-var">`andCts`</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101173"><span class="hs-identifier hs-var">no_flt_eqs</span></a></span><span>
</span><span id="line-2484"></span><span>
</span><span id="line-2485"></span><span>       </span><span class="hs-comment">-- Promote any unification variables mentioned in the floated equalities</span><span>
</span><span id="line-2486"></span><span>       </span><span class="hs-comment">-- See Note [Promoting unification variables]</span><span>
</span><span id="line-2487"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TcTyVar -&gt; TcS ()) -&gt; [TcTyVar] -&gt; TcS ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcS ()
</span><a href="GHC.Tc.Solver.html#promoteTyVarTcS"><span class="hs-identifier hs-var">promoteTyVarTcS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts -&gt; [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#tyCoVarsOfCtsList"><span class="hs-identifier hs-var">tyCoVarsOfCtsList</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101174"><span class="hs-identifier hs-var">flt_eqs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2488"></span><span>
</span><span id="line-2489"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;floatEqualities&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Skols =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681101192"><span class="hs-identifier hs-var">skols</span></a></span><span>
</span><span id="line-2490"></span><span>                                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Extended skols =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101176"><span class="hs-identifier hs-var">extended_skols</span></a></span><span>
</span><span id="line-2491"></span><span>                                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Simples =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Cts -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101186"><span class="hs-identifier hs-var">simples</span></a></span><span>
</span><span id="line-2492"></span><span>                                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Candidate eqs =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Cts -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101183"><span class="hs-identifier hs-var">candidate_eqs</span></a></span><span>
</span><span id="line-2493"></span><span>                                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Floated eqs =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Cts -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101174"><span class="hs-identifier hs-var">flt_eqs</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-2494"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Cts, WantedConstraints) -&gt; TcS (Cts, WantedConstraints)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101174"><span class="hs-identifier hs-var">flt_eqs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101188"><span class="hs-identifier hs-var">wanteds</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: Cts
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101171"><span class="hs-identifier hs-var">remaining_simples</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2495"></span><span>
</span><span id="line-2496"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2497"></span><span>    </span><span class="annot"><a href="#local-6989586621681101178"><span class="hs-identifier hs-type">add_non_flt_ct</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-2498"></span><span>    </span><span id="local-6989586621681101178"><span class="annot"><span class="annottext">add_non_flt_ct :: Ct -&gt; VarSet -&gt; VarSet
</span><a href="#local-6989586621681101178"><span class="hs-identifier hs-var hs-var">add_non_flt_ct</span></a></span></span><span> </span><span id="local-6989586621681101167"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101167"><span class="hs-identifier hs-var">ct</span></a></span></span><span> </span><span id="local-6989586621681101166"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101166"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isDerivedCt"><span class="hs-identifier hs-var">isDerivedCt</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101167"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101166"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-2499"></span><span>                          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; TcTyVar -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-identifier hs-var">extendVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101166"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ct -&gt; TcTyVar
</span><a href="GHC.Tc.Types.Constraint.html#ctEvId"><span class="hs-identifier hs-var">ctEvId</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101167"><span class="hs-identifier hs-var">ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2500"></span><span>
</span><span id="line-2501"></span><span>    </span><span class="annot"><a href="#local-6989586621681101172"><span class="hs-identifier hs-type">is_floatable</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2502"></span><span>    </span><span id="local-6989586621681101172"><span class="annot"><span class="annottext">is_floatable :: VarSet -&gt; Ct -&gt; Bool
</span><a href="#local-6989586621681101172"><span class="hs-identifier hs-var hs-var">is_floatable</span></a></span></span><span> </span><span id="local-6989586621681101164"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101164"><span class="hs-identifier hs-var">skols</span></a></span></span><span> </span><span id="local-6989586621681101163"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101163"><span class="hs-identifier hs-var">ct</span></a></span></span><span>
</span><span id="line-2503"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isDerivedCt"><span class="hs-identifier hs-var">isDerivedCt</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101163"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; VarSet
</span><a href="GHC.Tc.Types.Constraint.html#tyCoVarsOfCt"><span class="hs-identifier hs-var">tyCoVarsOfCt</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101163"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#disjointVarSet"><span class="hs-operator hs-var">`disjointVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101164"><span class="hs-identifier hs-var">skols</span></a></span><span>
</span><span id="line-2504"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ct -&gt; TcTyVar
</span><a href="GHC.Tc.Types.Constraint.html#ctEvId"><span class="hs-identifier hs-var">ctEvId</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101163"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101164"><span class="hs-identifier hs-var">skols</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2505"></span><span>
</span><span id="line-2506"></span><span>    </span><span class="annot"><a href="#local-6989586621681101175"><span class="hs-identifier hs-type">add_captured_ev_ids</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Cts"><span class="hs-identifier hs-type">Cts</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>
</span><span id="line-2507"></span><span>    </span><span id="local-6989586621681101175"><span class="annot"><span class="annottext">add_captured_ev_ids :: Cts -&gt; VarSet -&gt; VarSet
</span><a href="#local-6989586621681101175"><span class="hs-identifier hs-var hs-var">add_captured_ev_ids</span></a></span></span><span> </span><span id="local-6989586621681101162"><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101162"><span class="hs-identifier hs-var">cts</span></a></span></span><span> </span><span id="local-6989586621681101161"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101161"><span class="hs-identifier hs-var">skols</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; VarSet -&gt; VarSet) -&gt; VarSet -&gt; Cts -&gt; VarSet
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; VarSet -&gt; VarSet
</span><a href="#local-6989586621681101160"><span class="hs-identifier hs-var">extra_skol</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101162"><span class="hs-identifier hs-var">cts</span></a></span><span>
</span><span id="line-2508"></span><span>       </span><span class="hs-keyword">where</span><span>
</span><span id="line-2509"></span><span>         </span><span id="local-6989586621681101160"><span class="annot"><span class="annottext">extra_skol :: Ct -&gt; VarSet -&gt; VarSet
</span><a href="#local-6989586621681101160"><span class="hs-identifier hs-var hs-var">extra_skol</span></a></span></span><span> </span><span id="local-6989586621681101159"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101159"><span class="hs-identifier hs-var">ct</span></a></span></span><span> </span><span id="local-6989586621681101158"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101158"><span class="hs-identifier hs-var">acc</span></a></span></span><span>
</span><span id="line-2510"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isDerivedCt"><span class="hs-identifier hs-var">isDerivedCt</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101159"><span class="hs-identifier hs-var">ct</span></a></span><span>                           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101158"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-2511"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; VarSet
</span><a href="GHC.Tc.Types.Constraint.html#tyCoVarsOfCt"><span class="hs-identifier hs-var">tyCoVarsOfCt</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101159"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#intersectsVarSet"><span class="hs-operator hs-var">`intersectsVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101161"><span class="hs-identifier hs-var">skols</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; TcTyVar -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-identifier hs-var">extendVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101158"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ct -&gt; TcTyVar
</span><a href="GHC.Tc.Types.Constraint.html#ctEvId"><span class="hs-identifier hs-var">ctEvId</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101159"><span class="hs-identifier hs-var">ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2512"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101158"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-2513"></span><span>
</span><span id="line-2514"></span><span>    </span><span class="hs-comment">-- Identify which equalities are candidates for floating</span><span>
</span><span id="line-2515"></span><span>    </span><span class="hs-comment">-- Float out alpha ~ ty which might be unified outside</span><span>
</span><span id="line-2516"></span><span>    </span><span class="hs-comment">-- See Note [Which equalities to float]</span><span>
</span><span id="line-2517"></span><span>    </span><span id="local-6989586621681101181"><span class="annot"><span class="annottext">is_float_eq_candidate :: Ct -&gt; Bool
</span><a href="#local-6989586621681101181"><span class="hs-identifier hs-var hs-var">is_float_eq_candidate</span></a></span></span><span> </span><span id="local-6989586621681101157"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101157"><span class="hs-identifier hs-var">ct</span></a></span></span><span>
</span><span id="line-2518"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681101156"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101156"><span class="hs-identifier hs-var">pred</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Type
</span><a href="GHC.Tc.Types.Constraint.html#ctPred"><span class="hs-identifier hs-var">ctPred</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101157"><span class="hs-identifier hs-var">ct</span></a></span><span>
</span><span id="line-2519"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqPred"><span class="hs-identifier hs-type">EqPred</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="GHC.Core.Predicate.html#NomEq"><span class="hs-identifier hs-var">NomEq</span></a></span><span> </span><span id="local-6989586621681101153"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101153"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681101152"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101152"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Pred
</span><a href="GHC.Core.Predicate.html#classifyPredType"><span class="hs-identifier hs-var">classifyPredType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101156"><span class="hs-identifier hs-var">pred</span></a></span><span>
</span><span id="line-2520"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101157"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2521"></span><span>           </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CIrredCan"><span class="hs-identifier hs-type">CIrredCan</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>   </span><span class="hs-comment">-- See Note [Do not float blocked constraints]</span><span>
</span><span id="line-2522"></span><span>           </span><span class="annot"><span class="annottext">Ct
</span><span class="hs-identifier">_</span></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>    </span><span class="hs-comment">--   See #18855</span><span>
</span><span id="line-2523"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Bool
</span><a href="#local-6989586621681101150"><span class="hs-identifier hs-var">float_eq</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101153"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101152"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Bool
</span><a href="#local-6989586621681101150"><span class="hs-identifier hs-var">float_eq</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101152"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101153"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-2524"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2525"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2526"></span><span>
</span><span id="line-2527"></span><span>    </span><span id="local-6989586621681101150"><span class="annot"><span class="annottext">float_eq :: Type -&gt; Type -&gt; Bool
</span><a href="#local-6989586621681101150"><span class="hs-identifier hs-var hs-var">float_eq</span></a></span></span><span> </span><span id="local-6989586621681101149"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101149"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681101148"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101148"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-2528"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe TcTyVar
</span><a href="GHC.Core.Type.html#getTyVar_maybe"><span class="hs-identifier hs-var">getTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101149"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2529"></span><span>          </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681101146"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101146"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isMetaTyVar"><span class="hs-identifier hs-var">isMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101146"><span class="hs-identifier hs-var">tv1</span></a></span><span>
</span><span id="line-2530"></span><span>                   </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isTyVarTyVar"><span class="hs-identifier hs-var">isTyVarTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101146"><span class="hs-identifier hs-var">tv1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Type.html#isTyVarTy"><span class="hs-identifier hs-var">isTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101148"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2531"></span><span>          </span><span class="annot"><span class="annottext">Maybe TcTyVar
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2532"></span><span>
</span><span id="line-2533"></span><span class="hs-comment">{- Note [Do not float blocked constraints]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As #18855 showed, we must not float an equality that is blocked.
Consider
     forall a[4]. [W] co1: alpha[4] ~ Maybe (a[4] |&gt; bco)
                  [W] co2: alpha[4] ~ Maybe (beta[4] |&gt; bco])
                  [W] bco: kappa[2] ~ Type

Now co1, co2 are blocked by bco.  We will eventually float out bco
and solve it at level 2.  But the danger is that we will *also*
float out co2, and that is bad bad bad.  Because we'll promote alpha
and beta to level 2, and then fail to unify the promoted beta
with the skolem a[4].

Solution: don't float out blocked equalities. Remember: we only want
to float out if we can solve; see Note [Which equalities to float].

(Future plan: kill floating altogether.)

Note [Float equalities from under a skolem binding]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Which of the simple equalities can we float out?  Obviously, only
ones that don't mention the skolem-bound variables.  But that is
over-eager. Consider
   [2] forall a. F a beta[1] ~ gamma[2], G beta[1] gamma[2] ~ Int
The second constraint doesn't mention 'a'.  But if we float it,
we'll promote gamma[2] to gamma'[1].  Now suppose that we learn that
beta := Bool, and F a Bool = a, and G Bool _ = Int.  Then we'll
we left with the constraint
   [2] forall a. a ~ gamma'[1]
which is insoluble because gamma became untouchable.

Solution: float only constraints that stand a jolly good chance of
being soluble simply by being floated, namely ones of form
      a ~ ty
where 'a' is a currently-untouchable unification variable, but may
become touchable by being floated (perhaps by more than one level).

We had a very complicated rule previously, but this is nice and
simple.  (To see the notes, look at this Note in a version of
GHC.Tc.Solver prior to Oct 2014).

Note [Which equalities to float]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Which equalities should we float?  We want to float ones where there
is a decent chance that floating outwards will allow unification to
happen.  In particular, float out equalities that are:

* Of form (alpha ~# ty) or (ty ~# alpha), where
   * alpha is a meta-tyvar.
   * And 'alpha' is not a TyVarTv with 'ty' being a non-tyvar.  In that
     case, floating out won't help either, and it may affect grouping
     of error messages.

  NB: generally we won't see (ty ~ alpha), with alpha on the right because
  of Note [Unification variables on the left] in GHC.Tc.Utils.Unify.
  But if we start with (F tys ~ alpha), it will orient as (fmv ~ alpha),
  and unflatten back to (F tys ~ alpha). So we must look for alpha on
  the right too.  Example T4494.

* Nominal.  No point in floating (alpha ~R# ty), because we do not
  unify representational equalities even if alpha is touchable.
  See Note [Do not unify representational equalities] in GHC.Tc.Solver.Interact.

Note [Skolem escape]
~~~~~~~~~~~~~~~~~~~~
You might worry about skolem escape with all this floating.
For example, consider
    [2] forall a. (a ~ F beta[2] delta,
                   Maybe beta[2] ~ gamma[1])

The (Maybe beta ~ gamma) doesn't mention 'a', so we float it, and
solve with gamma := beta. But what if later delta:=Int, and
  F b Int = b.
Then we'd get a ~ beta[2], and solve to get beta:=a, and now the
skolem has escaped!

But it's ok: when we float (Maybe beta[2] ~ gamma[1]), we promote beta[2]
to beta[1], and that means the (a ~ beta[1]) will be stuck, as it should be.

Note [What prevents a constraint from floating]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
What /prevents/ a constraint from floating?  If it mentions one of the
&quot;bound variables of the implication&quot;.  What are they?

The &quot;bound variables of the implication&quot; are

  1. The skolem type variables `ic_skols`

  2. The &quot;given&quot; evidence variables `ic_given`.  Example:
         forall a. (co :: t1 ~# t2) =&gt;  [W] co2 : (a ~# b |&gt; co)
     Here 'co' is bound

  3. The binders of all evidence bindings in `ic_binds`. Example
         forall a. (d :: t1 ~ t2)
            EvBinds { (co :: t1 ~# t2) = superclass-sel d }
            =&gt; [W] co2 : (a ~# b |&gt; co)
     Here `co` is gotten by superclass selection from `d`, and the
     wanted constraint co2 must not float.

  4. And the evidence variable of any equality constraint (incl
     Wanted ones) whose type mentions a bound variable.  Example:
        forall k. [W] co1 :: t1 ~# t2 |&gt; co2
                  [W] co2 :: k ~# *
     Here, since `k` is bound, so is `co2` and hence so is `co1`.

Here (1,2,3) are handled by the &quot;seed_skols&quot; calculation, and
(4) is done by the transCloVarSet call.

The possible dependence on givens, and evidence bindings, is more
subtle than we'd realised at first.  See #14584.

How can (4) arise? Suppose we have (k :: *), (a :: k), and ([G} k ~ *).
Then form an equality like (a ~ Int) we might end up with
    [W] co1 :: k ~ *
    [W] co2 :: (a |&gt; co1) ~ Int


*********************************************************************************
*                                                                               *
*                          Defaulting and disambiguation                        *
*                                                                               *
*********************************************************************************
-}</span><span>
</span><span id="line-2657"></span><span>
</span><span id="line-2658"></span><span class="annot"><a href="GHC.Tc.Solver.html#applyDefaultingRules"><span class="hs-identifier hs-type">applyDefaultingRules</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2659"></span><span class="hs-comment">-- True &lt;=&gt; I did some defaulting, by unifying a meta-tyvar</span><span>
</span><span id="line-2660"></span><span class="hs-comment">-- Input WantedConstraints are not necessarily zonked</span><span>
</span><span id="line-2661"></span><span>
</span><span id="line-2662"></span><span id="applyDefaultingRules"><span class="annot"><span class="annottext">applyDefaultingRules :: WantedConstraints -&gt; TcS Bool
</span><a href="GHC.Tc.Solver.html#applyDefaultingRules"><span class="hs-identifier hs-var hs-var">applyDefaultingRules</span></a></span></span><span> </span><span id="local-6989586621681101144"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101144"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span>
</span><span id="line-2663"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isEmptyWC"><span class="hs-identifier hs-var">isEmptyWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101144"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-2664"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcS Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2665"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2666"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101143"><span class="annot"><span class="annottext">info :: ([Type], (Bool, Bool))
</span><a href="#local-6989586621681101143"><span class="hs-identifier hs-var">info</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621681101142"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101142"><span class="hs-identifier hs-var">default_tys</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(Bool, Bool)
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS ([Type], (Bool, Bool))
</span><a href="GHC.Tc.Solver.Monad.html#getDefaultInfo"><span class="hs-identifier hs-var">getDefaultInfo</span></a></span><span>
</span><span id="line-2667"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101140"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101140"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span>               </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.Monad.html#zonkWC"><span class="hs-identifier hs-var">TcS.zonkWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101144"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-2668"></span><span>
</span><span id="line-2669"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101138"><span class="annot"><span class="annottext">groups :: [(TcTyVar, [Ct])]
</span><a href="#local-6989586621681101138"><span class="hs-identifier hs-var hs-var">groups</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Type], (Bool, Bool)) -&gt; WantedConstraints -&gt; [(TcTyVar, [Ct])]
</span><a href="GHC.Tc.Solver.html#findDefaultableGroups"><span class="hs-identifier hs-var">findDefaultableGroups</span></a></span><span> </span><span class="annot"><span class="annottext">([Type], (Bool, Bool))
</span><a href="#local-6989586621681101143"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101140"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-2670"></span><span>
</span><span id="line-2671"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;applyDefaultingRules {&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcS ()) -&gt; SDoc -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-2672"></span><span>                  </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;wanteds =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101140"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-2673"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;groups  =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[(TcTyVar, [Ct])] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[(TcTyVar, [Ct])]
</span><a href="#local-6989586621681101138"><span class="hs-identifier hs-var">groups</span></a></span><span>
</span><span id="line-2674"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;info    =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">([Type], (Bool, Bool)) -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">([Type], (Bool, Bool))
</span><a href="#local-6989586621681101143"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-2675"></span><span>
</span><span id="line-2676"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101136"><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621681101136"><span class="hs-identifier hs-var">something_happeneds</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">((TcTyVar, [Ct]) -&gt; TcS Bool) -&gt; [(TcTyVar, [Ct])] -&gt; TcS [Bool]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; (TcTyVar, [Ct]) -&gt; TcS Bool
</span><a href="GHC.Tc.Solver.html#disambigGroup"><span class="hs-identifier hs-var">disambigGroup</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101142"><span class="hs-identifier hs-var">default_tys</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(TcTyVar, [Ct])]
</span><a href="#local-6989586621681101138"><span class="hs-identifier hs-var">groups</span></a></span><span>
</span><span id="line-2677"></span><span>
</span><span id="line-2678"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;applyDefaultingRules }&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Bool] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621681101136"><span class="hs-identifier hs-var">something_happeneds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2679"></span><span>
</span><span id="line-2680"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcS Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Bool] -&gt; Bool
forall (t :: * -&gt; *). Foldable t =&gt; t Bool -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#or"><span class="hs-identifier hs-var">or</span></a></span><span> </span><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621681101136"><span class="hs-identifier hs-var">something_happeneds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2681"></span><span>
</span><span id="line-2682"></span><span class="annot"><a href="GHC.Tc.Solver.html#findDefaultableGroups"><span class="hs-identifier hs-type">findDefaultableGroups</span></a></span><span>
</span><span id="line-2683"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2684"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">,</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>     </span><span class="hs-comment">-- (Overloaded strings, extended default rules)</span><span>
</span><span id="line-2685"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>   </span><span class="hs-comment">-- Unsolved (wanted or derived)</span><span>
</span><span id="line-2686"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-2687"></span><span id="findDefaultableGroups"><span class="annot"><span class="annottext">findDefaultableGroups :: ([Type], (Bool, Bool)) -&gt; WantedConstraints -&gt; [(TcTyVar, [Ct])]
</span><a href="GHC.Tc.Solver.html#findDefaultableGroups"><span class="hs-identifier hs-var hs-var">findDefaultableGroups</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101134"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101134"><span class="hs-identifier hs-var">default_tys</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101133"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101133"><span class="hs-identifier hs-var">ovl_strings</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101132"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101132"><span class="hs-identifier hs-var">extended_defaults</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681101131"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101131"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span>
</span><span id="line-2688"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101134"><span class="hs-identifier hs-var">default_tys</span></a></span><span>
</span><span id="line-2689"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-2690"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2691"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101130"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">((Ct, Class, TcTyVar) -&gt; Ct) -&gt; [(Ct, Class, TcTyVar)] -&gt; [Ct]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Ct, Class, TcTyVar) -&gt; Ct
forall a b c. (a, b, c) -&gt; a
</span><a href="GHC.Utils.Misc.html#fstOf3"><span class="hs-identifier hs-var">fstOf3</span></a></span><span> </span><span class="annot"><span class="annottext">[(Ct, Class, TcTyVar)]
</span><a href="#local-6989586621681101128"><span class="hs-identifier hs-var">group</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2692"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681101127"><span class="annot"><span class="annottext">group' :: NonEmpty (Ct, Class, TcTyVar)
</span><a href="#local-6989586621681101127"><span class="hs-identifier hs-var">group'</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ct
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Class
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621681101130"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101130"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3A%7C"><span class="hs-operator hs-type">:|</span></a></span><span> </span><span class="annot"><span class="annottext">[(Ct, Class, TcTyVar)]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[NonEmpty (Ct, Class, TcTyVar)]
</span><a href="#local-6989586621681101125"><span class="hs-identifier hs-var">unary_groups</span></a></span><span>
</span><span id="line-2693"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101128"><span class="annot"><span class="annottext">group :: [(Ct, Class, TcTyVar)]
</span><a href="#local-6989586621681101128"><span class="hs-identifier hs-var hs-var">group</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NonEmpty (Ct, Class, TcTyVar) -&gt; [(Ct, Class, TcTyVar)]
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#toList"><span class="hs-identifier hs-var">toList</span></a></span><span> </span><span class="annot"><span class="annottext">NonEmpty (Ct, Class, TcTyVar)
</span><a href="#local-6989586621681101127"><span class="hs-identifier hs-var">group'</span></a></span><span>
</span><span id="line-2694"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="#local-6989586621681101122"><span class="hs-identifier hs-var">defaultable_tyvar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101130"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2695"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Class] -&gt; Bool
</span><a href="#local-6989586621681101121"><span class="hs-identifier hs-var">defaultable_classes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((Ct, Class, TcTyVar) -&gt; Class)
-&gt; [(Ct, Class, TcTyVar)] -&gt; [Class]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Ct, Class, TcTyVar) -&gt; Class
forall a b c. (a, b, c) -&gt; b
</span><a href="GHC.Utils.Misc.html#sndOf3"><span class="hs-identifier hs-var">sndOf3</span></a></span><span> </span><span class="annot"><span class="annottext">[(Ct, Class, TcTyVar)]
</span><a href="#local-6989586621681101128"><span class="hs-identifier hs-var">group</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-2696"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2697"></span><span>    </span><span id="local-6989586621681101119"><span class="annot"><span class="annottext">simples :: Cts
</span><a href="#local-6989586621681101119"><span class="hs-identifier hs-var hs-var">simples</span></a></span></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; WantedConstraints -&gt; Cts
</span><a href="GHC.Tc.Solver.html#approximateWC"><span class="hs-identifier hs-var">approximateWC</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681101131"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-2698"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681101118"><span class="annot"><span class="annottext">[(Ct, Class, TcTyVar)]
</span><a href="#local-6989586621681101118"><span class="hs-identifier hs-var">unaries</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101117"><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101117"><span class="hs-identifier hs-var">non_unaries</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; Either (Ct, Class, TcTyVar) Ct)
-&gt; [Ct] -&gt; ([(Ct, Class, TcTyVar)], [Ct])
forall a b c. (a -&gt; Either b c) -&gt; [a] -&gt; ([b], [c])
</span><a href="GHC.Utils.Misc.html#partitionWith"><span class="hs-identifier hs-var">partitionWith</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Either (Ct, Class, TcTyVar) Ct
</span><a href="#local-6989586621681101115"><span class="hs-identifier hs-var">find_unary</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Cts -&gt; [Ct]
forall a. Bag a -&gt; [a]
</span><a href="GHC.Data.Bag.html#bagToList"><span class="hs-identifier hs-var">bagToList</span></a></span><span> </span><span class="annot"><span class="annottext">Cts
</span><a href="#local-6989586621681101119"><span class="hs-identifier hs-var">simples</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2699"></span><span>    </span><span id="local-6989586621681101125"><span class="annot"><span class="annottext">unary_groups :: [NonEmpty (Ct, Class, TcTyVar)]
</span><a href="#local-6989586621681101125"><span class="hs-identifier hs-var hs-var">unary_groups</span></a></span></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Ct, Class, TcTyVar) -&gt; (Ct, Class, TcTyVar) -&gt; Ordering)
-&gt; [(Ct, Class, TcTyVar)] -&gt; [NonEmpty (Ct, Class, TcTyVar)]
forall a. (a -&gt; a -&gt; Ordering) -&gt; [a] -&gt; [NonEmpty a]
</span><a href="GHC.Data.List.SetOps.html#equivClasses"><span class="hs-identifier hs-var">equivClasses</span></a></span><span> </span><span class="annot"><span class="annottext">(Ct, Class, TcTyVar) -&gt; (Ct, Class, TcTyVar) -&gt; Ordering
forall {a} {a} {b} {a} {b}.
Ord a =&gt;
(a, b, a) -&gt; (a, b, a) -&gt; Ordering
</span><a href="#local-6989586621681101113"><span class="hs-identifier hs-var">cmp_tv</span></a></span><span> </span><span class="annot"><span class="annottext">[(Ct, Class, TcTyVar)]
</span><a href="#local-6989586621681101118"><span class="hs-identifier hs-var">unaries</span></a></span><span>
</span><span id="line-2700"></span><span>
</span><span id="line-2701"></span><span>    </span><span class="annot"><a href="#local-6989586621681101125"><span class="hs-identifier hs-type">unary_groups</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#NonEmpty"><span class="hs-identifier hs-type">NonEmpty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- (C tv) constraints</span><span>
</span><span id="line-2702"></span><span>    </span><span class="annot"><a href="#local-6989586621681101118"><span class="hs-identifier hs-type">unaries</span></a></span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>          </span><span class="hs-comment">-- (C tv) constraints</span><span>
</span><span id="line-2703"></span><span>    </span><span class="annot"><a href="#local-6989586621681101117"><span class="hs-identifier hs-type">non_unaries</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">]</span><span>                            </span><span class="hs-comment">-- and *other* constraints</span><span>
</span><span id="line-2704"></span><span>
</span><span id="line-2705"></span><span>        </span><span class="hs-comment">-- Finds unary type-class constraints</span><span>
</span><span id="line-2706"></span><span>        </span><span class="hs-comment">-- But take account of polykinded classes like Typeable,</span><span>
</span><span id="line-2707"></span><span>        </span><span class="hs-comment">-- which may look like (Typeable * (a:*))   (#8931)</span><span>
</span><span id="line-2708"></span><span>    </span><span class="annot"><a href="#local-6989586621681101115"><span class="hs-identifier hs-type">find_unary</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span>
</span><span id="line-2709"></span><span>    </span><span id="local-6989586621681101115"><span class="annot"><span class="annottext">find_unary :: Ct -&gt; Either (Ct, Class, TcTyVar) Ct
</span><a href="#local-6989586621681101115"><span class="hs-identifier hs-var hs-var">find_unary</span></a></span></span><span> </span><span id="local-6989586621681101112"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101112"><span class="hs-identifier hs-var">cc</span></a></span></span><span>
</span><span id="line-2710"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101111"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101111"><span class="hs-identifier hs-var">cls</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681101110"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101110"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Class, [Type])
</span><a href="GHC.Core.Predicate.html#getClassPredTys_maybe"><span class="hs-identifier hs-var">getClassPredTys_maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ct -&gt; Type
</span><a href="GHC.Tc.Types.Constraint.html#ctPred"><span class="hs-identifier hs-var">ctPred</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101112"><span class="hs-identifier hs-var">cc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2711"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621681101109"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101109"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [Type] -&gt; [Type]
</span><a href="GHC.Core.Type.html#filterOutInvisibleTypes"><span class="hs-identifier hs-var">filterOutInvisibleTypes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; TyCon
</span><a href="GHC.Core.Class.html#classTyCon"><span class="hs-identifier hs-var hs-var">classTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101111"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101110"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-2712"></span><span>              </span><span class="hs-comment">-- Ignore invisible arguments for this purpose</span><span>
</span><span id="line-2713"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681101107"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101107"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe TcTyVar
</span><a href="GHC.Tc.Utils.TcType.html#tcGetTyVar_maybe"><span class="hs-identifier hs-var">tcGetTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101109"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2714"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isMetaTyVar"><span class="hs-identifier hs-var">isMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101107"><span class="hs-identifier hs-var">tv</span></a></span><span>  </span><span class="hs-comment">-- We might have runtime-skolems in GHCi, and</span><span>
</span><span id="line-2715"></span><span>                          </span><span class="hs-comment">-- we definitely don't want to try to assign to those!</span><span>
</span><span id="line-2716"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Ct, Class, TcTyVar) -&gt; Either (Ct, Class, TcTyVar) Ct
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101112"><span class="hs-identifier hs-var">cc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101111"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101107"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2717"></span><span>    </span><span class="annot"><a href="#local-6989586621681101115"><span class="hs-identifier hs-var">find_unary</span></a></span><span> </span><span id="local-6989586621681101105"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101105"><span class="hs-identifier hs-var">cc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Either (Ct, Class, TcTyVar) Ct
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681101105"><span class="hs-identifier hs-var">cc</span></a></span><span>  </span><span class="hs-comment">-- Non unary or non dictionary</span><span>
</span><span id="line-2718"></span><span>
</span><span id="line-2719"></span><span>    </span><span class="annot"><a href="#local-6989586621681101104"><span class="hs-identifier hs-type">bad_tvs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyCoVarSet"><span class="hs-identifier hs-type">TcTyCoVarSet</span></a></span><span>  </span><span class="hs-comment">-- TyVars mentioned by non-unaries</span><span>
</span><span id="line-2720"></span><span>    </span><span id="local-6989586621681101104"><span class="annot"><span class="annottext">bad_tvs :: VarSet
</span><a href="#local-6989586621681101104"><span class="hs-identifier hs-var hs-var">bad_tvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; VarSet) -&gt; [Ct] -&gt; VarSet
forall a. (a -&gt; VarSet) -&gt; [a] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mapUnionVarSet"><span class="hs-identifier hs-var">mapUnionVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; VarSet
</span><a href="GHC.Tc.Types.Constraint.html#tyCoVarsOfCt"><span class="hs-identifier hs-var">tyCoVarsOfCt</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101117"><span class="hs-identifier hs-var">non_unaries</span></a></span><span>
</span><span id="line-2721"></span><span>
</span><span id="line-2722"></span><span>    </span><span id="local-6989586621681101113"><span class="annot"><span class="annottext">cmp_tv :: (a, b, a) -&gt; (a, b, a) -&gt; Ordering
</span><a href="#local-6989586621681101113"><span class="hs-identifier hs-var hs-var">cmp_tv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">b
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621681101100"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681101100"><span class="hs-identifier hs-var">tv1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">b
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621681101099"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681101099"><span class="hs-identifier hs-var">tv2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681101100"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; a -&gt; Ordering
forall a. Ord a =&gt; a -&gt; a -&gt; Ordering
</span><span class="hs-operator hs-var">`compare`</span></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681101099"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-2723"></span><span>
</span><span id="line-2724"></span><span>    </span><span class="annot"><a href="#local-6989586621681101122"><span class="hs-identifier hs-type">defaultable_tyvar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2725"></span><span>    </span><span id="local-6989586621681101122"><span class="annot"><span class="annottext">defaultable_tyvar :: TcTyVar -&gt; Bool
</span><a href="#local-6989586621681101122"><span class="hs-identifier hs-var hs-var">defaultable_tyvar</span></a></span></span><span> </span><span id="local-6989586621681101097"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101097"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-2726"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101096"><span class="annot"><span class="annottext">b1 :: Bool
</span><a href="#local-6989586621681101096"><span class="hs-identifier hs-var hs-var">b1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isTyConableTyVar"><span class="hs-identifier hs-var">isTyConableTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101097"><span class="hs-identifier hs-var">tv</span></a></span><span>  </span><span class="hs-comment">-- Note [Avoiding spurious errors]</span><span>
</span><span id="line-2727"></span><span>              </span><span id="local-6989586621681101094"><span class="annot"><span class="annottext">b2 :: Bool
</span><a href="#local-6989586621681101094"><span class="hs-identifier hs-var hs-var">b2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101097"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681101104"><span class="hs-identifier hs-var">bad_tvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2728"></span><span>          </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101096"><span class="hs-identifier hs-var">b1</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101094"><span class="hs-identifier hs-var">b2</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101132"><span class="hs-identifier hs-var">extended_defaults</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Note [Multi-parameter defaults]</span><span>
</span><span id="line-2729"></span><span>
</span><span id="line-2730"></span><span>    </span><span class="annot"><a href="#local-6989586621681101121"><span class="hs-identifier hs-type">defaultable_classes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2731"></span><span>    </span><span id="local-6989586621681101121"><span class="annot"><span class="annottext">defaultable_classes :: [Class] -&gt; Bool
</span><a href="#local-6989586621681101121"><span class="hs-identifier hs-var hs-var">defaultable_classes</span></a></span></span><span> </span><span id="local-6989586621681101093"><span class="annot"><span class="annottext">[Class]
</span><a href="#local-6989586621681101093"><span class="hs-identifier hs-var">clss</span></a></span></span><span>
</span><span id="line-2732"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101132"><span class="hs-identifier hs-var">extended_defaults</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Class -&gt; Bool) -&gt; [Class] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Class -&gt; Bool
</span><a href="GHC.Tc.Solver.html#isInteractiveClass"><span class="hs-identifier hs-var">isInteractiveClass</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101133"><span class="hs-identifier hs-var">ovl_strings</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Class]
</span><a href="#local-6989586621681101093"><span class="hs-identifier hs-var">clss</span></a></span><span>
</span><span id="line-2733"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Class -&gt; Bool) -&gt; [Class] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">Class -&gt; Bool
</span><a href="#local-6989586621681101091"><span class="hs-identifier hs-var">is_std_class</span></a></span><span> </span><span class="annot"><span class="annottext">[Class]
</span><a href="#local-6989586621681101093"><span class="hs-identifier hs-var">clss</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Class -&gt; Bool) -&gt; [Class] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Class -&gt; Bool
</span><a href="GHC.Tc.Solver.html#isNumClass"><span class="hs-identifier hs-var">isNumClass</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101133"><span class="hs-identifier hs-var">ovl_strings</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Class]
</span><a href="#local-6989586621681101093"><span class="hs-identifier hs-var">clss</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2734"></span><span>
</span><span id="line-2735"></span><span>    </span><span class="hs-comment">-- is_std_class adds IsString to the standard numeric classes,</span><span>
</span><span id="line-2736"></span><span>    </span><span class="hs-comment">-- when -foverloaded-strings is enabled</span><span>
</span><span id="line-2737"></span><span>    </span><span id="local-6989586621681101091"><span class="annot"><span class="annottext">is_std_class :: Class -&gt; Bool
</span><a href="#local-6989586621681101091"><span class="hs-identifier hs-var hs-var">is_std_class</span></a></span></span><span> </span><span id="local-6989586621681101088"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101088"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; Bool
</span><a href="GHC.Builtin.Utils.html#isStandardClass"><span class="hs-identifier hs-var">isStandardClass</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101088"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span>
</span><span id="line-2738"></span><span>                       </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101133"><span class="hs-identifier hs-var">ovl_strings</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101088"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">Class -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#isStringClassKey"><span class="hs-identifier hs-var">isStringClassKey</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2739"></span><span>
</span><span id="line-2740"></span><span class="hs-comment">------------------------------</span><span>
</span><span id="line-2741"></span><span class="annot"><a href="GHC.Tc.Solver.html#disambigGroup"><span class="hs-identifier hs-type">disambigGroup</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>            </span><span class="hs-comment">-- The default types</span><span>
</span><span id="line-2742"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- All classes of the form (C a)</span><span>
</span><span id="line-2743"></span><span>                                   </span><span class="hs-comment">--  sharing same type variable</span><span>
</span><span id="line-2744"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Solver.Monad.html#TcS"><span class="hs-identifier hs-type">TcS</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>   </span><span class="hs-comment">-- True &lt;=&gt; something happened, reflected in ty_binds</span><span>
</span><span id="line-2745"></span><span>
</span><span id="line-2746"></span><span id="disambigGroup"><span class="annot"><span class="annottext">disambigGroup :: [Type] -&gt; (TcTyVar, [Ct]) -&gt; TcS Bool
</span><a href="GHC.Tc.Solver.html#disambigGroup"><span class="hs-identifier hs-var hs-var">disambigGroup</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">(TcTyVar, [Ct])
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-2747"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcS Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2748"></span><span class="annot"><a href="GHC.Tc.Solver.html#disambigGroup"><span class="hs-identifier hs-var">disambigGroup</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681101084"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101084"><span class="hs-identifier hs-var">default_ty</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681101083"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101083"><span class="hs-identifier hs-var">default_tys</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681101082"><span class="annot"><span class="annottext">group :: (TcTyVar, [Ct])
</span><a href="#local-6989586621681101082"><span class="hs-identifier hs-var">group</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621681101081"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101081"><span class="hs-identifier hs-var">the_tv</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681101080"><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101080"><span class="hs-identifier hs-var">wanteds</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2749"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;disambigGroup {&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101084"><span class="hs-identifier hs-var">default_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101081"><span class="hs-identifier hs-var">the_tv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101080"><span class="hs-identifier hs-var">wanteds</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-2750"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101079"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101079"><span class="hs-identifier hs-var">fake_ev_binds_var</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS EvBindsVar
</span><a href="GHC.Tc.Solver.Monad.html#newTcEvBinds"><span class="hs-identifier hs-var">TcS.newTcEvBinds</span></a></span><span>
</span><span id="line-2751"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101077"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101077"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span>             </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS TcLevel
</span><a href="GHC.Tc.Solver.Monad.html#getTcLevel"><span class="hs-identifier hs-var">TcS.getTcLevel</span></a></span><span>
</span><span id="line-2752"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101076"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101076"><span class="hs-identifier hs-var">success</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; TcLevel -&gt; TcS Bool -&gt; TcS Bool
forall a. EvBindsVar -&gt; TcLevel -&gt; TcS a -&gt; TcS a
</span><a href="GHC.Tc.Solver.Monad.html#nestImplicTcS"><span class="hs-identifier hs-var">nestImplicTcS</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681101079"><span class="hs-identifier hs-var">fake_ev_binds_var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcLevel -&gt; TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#pushTcLevel"><span class="hs-identifier hs-var">pushTcLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101077"><span class="hs-identifier hs-var">tclvl</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcS Bool
</span><a href="#local-6989586621681101074"><span class="hs-identifier hs-var">try_group</span></a></span><span>
</span><span id="line-2753"></span><span>
</span><span id="line-2754"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101076"><span class="hs-identifier hs-var">success</span></a></span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-2755"></span><span>             </span><span class="hs-comment">-- Success: record the type variable binding, and return</span><span>
</span><span id="line-2756"></span><span>             </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Type -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#unifyTyVar"><span class="hs-identifier hs-var">unifyTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101081"><span class="hs-identifier hs-var">the_tv</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101084"><span class="hs-identifier hs-var">default_ty</span></a></span><span>
</span><span id="line-2757"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcM () -&gt; TcS ()
forall a. TcM a -&gt; TcS a
</span><a href="GHC.Tc.Solver.Monad.html#wrapWarnTcS"><span class="hs-identifier hs-var">wrapWarnTcS</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM () -&gt; TcS ()) -&gt; TcM () -&gt; TcS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; Type -&gt; TcM ()
</span><a href="GHC.Tc.Errors.html#warnDefaulting"><span class="hs-identifier hs-var">warnDefaulting</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101080"><span class="hs-identifier hs-var">wanteds</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101084"><span class="hs-identifier hs-var">default_ty</span></a></span><span>
</span><span id="line-2758"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;disambigGroup succeeded }&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101084"><span class="hs-identifier hs-var">default_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2759"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcS Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2760"></span><span>         </span><span class="hs-keyword">else</span><span>
</span><span id="line-2761"></span><span>             </span><span class="hs-comment">-- Failure: try with the next type</span><span>
</span><span id="line-2762"></span><span>             </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcS ()
</span><a href="GHC.Tc.Solver.Monad.html#traceTcS"><span class="hs-identifier hs-var">traceTcS</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;disambigGroup failed, will try other default types }&quot;</span></span><span>
</span><span id="line-2763"></span><span>                           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101084"><span class="hs-identifier hs-var">default_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2764"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; (TcTyVar, [Ct]) -&gt; TcS Bool
</span><a href="GHC.Tc.Solver.html#disambigGroup"><span class="hs-identifier hs-var">disambigGroup</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681101083"><span class="hs-identifier hs-var">default_tys</span></a></span><span> </span><span class="annot"><span class="annottext">(TcTyVar, [Ct])
</span><a href="#local-6989586621681101082"><span class="hs-identifier hs-var">group</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2765"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2766"></span><span>    </span><span id="local-6989586621681101074"><span class="annot"><span class="annottext">try_group :: TcS Bool
</span><a href="#local-6989586621681101074"><span class="hs-identifier hs-var hs-var">try_group</span></a></span></span><span>
</span><span id="line-2767"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681101062"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681101062"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe TCvSubst
</span><a href="#local-6989586621681101061"><span class="hs-identifier hs-var">mb_subst</span></a></span><span>
</span><span id="line-2768"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681101060"><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681101060"><span class="hs-identifier hs-var">lcl_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS TcLclEnv
</span><a href="GHC.Tc.Solver.Monad.html#getLclEnv"><span class="hs-identifier hs-var">TcS.getLclEnv</span></a></span><span>
</span><span id="line-2769"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101058"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101058"><span class="hs-identifier hs-var">tc_lvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcS TcLevel
</span><a href="GHC.Tc.Solver.Monad.html#getTcLevel"><span class="hs-identifier hs-var">TcS.getTcLevel</span></a></span><span>
</span><span id="line-2770"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681101057"><span class="annot"><span class="annottext">loc :: CtLoc
</span><a href="#local-6989586621681101057"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; SkolemInfo -&gt; TcLclEnv -&gt; CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#mkGivenLoc"><span class="hs-identifier hs-var">mkGivenLoc</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681101058"><span class="hs-identifier hs-var">tc_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#UnkSkol"><span class="hs-identifier hs-var">UnkSkol</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681101060"><span class="hs-identifier hs-var">lcl_env</span></a></span><span>
</span><span id="line-2771"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681101056"><span class="annot"><span class="annottext">[CtEvidence]
</span><a href="#local-6989586621681101056"><span class="hs-identifier hs-var">wanted_evs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; TcS CtEvidence) -&gt; [Ct] -&gt; TcS [CtEvidence]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtLoc -&gt; Type -&gt; TcS CtEvidence
</span><a href="GHC.Tc.Solver.Monad.html#newWantedEvVarNC"><span class="hs-identifier hs-var">newWantedEvVarNC</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681101057"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; TcS CtEvidence) -&gt; (Ct -&gt; Type) -&gt; Ct -&gt; TcS CtEvidence
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681101062"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; (Ct -&gt; Type) -&gt; Ct -&gt; Type
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; Type
</span><a href="GHC.Tc.Types.Constraint.html#ctPred"><span class="hs-identifier hs-var">ctPred</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2772"></span><span>                                </span><span class="annot"><span class="annottext">[Ct]
</span><a href="#local-6989586621681101080"><span class="hs-identifier hs-var">wanteds</span></a></span><span>
</span><span id="line-2773"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(WantedConstraints -&gt; Bool) -&gt; TcS WantedConstraints -&gt; TcS Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isEmptyWC"><span class="hs-identifier hs-var">isEmptyWC</span></a></span><span> </span><span class="annot"><span class="annottext">(TcS WantedConstraints -&gt; TcS Bool)
-&gt; TcS WantedConstraints -&gt; TcS Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-2774"></span><span>             </span><span class="annot"><span class="annottext">Cts -&gt; TcS WantedConstraints
</span><a href="GHC.Tc.Solver.Interact.html#solveSimpleWanteds"><span class="hs-identifier hs-var">solveSimpleWanteds</span></a></span><span> </span><span class="annot"><span class="annottext">(Cts -&gt; TcS WantedConstraints) -&gt; Cts -&gt; TcS WantedConstraints
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Ct] -&gt; Cts
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">([Ct] -&gt; Cts) -&gt; [Ct] -&gt; Cts
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-2775"></span><span>             </span><span class="annot"><span class="annottext">(CtEvidence -&gt; Ct) -&gt; [CtEvidence] -&gt; [Ct]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkNonCanonical"><span class="hs-identifier hs-var">mkNonCanonical</span></a></span><span> </span><span class="annot"><span class="annottext">[CtEvidence]
</span><a href="#local-6989586621681101056"><span class="hs-identifier hs-var">wanted_evs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2776"></span><span>
</span><span id="line-2777"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2778"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcS Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2779"></span><span>
</span><span id="line-2780"></span><span>    </span><span id="local-6989586621681101052"><span class="annot"><span class="annottext">the_ty :: Type
</span><a href="#local-6989586621681101052"><span class="hs-identifier hs-var hs-var">the_ty</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681101081"><span class="hs-identifier hs-var">the_tv</span></a></span><span>
</span><span id="line-2781"></span><span>    </span><span id="local-6989586621681101061"><span class="annot"><span class="annottext">mb_subst :: Maybe TCvSubst
</span><a href="#local-6989586621681101061"><span class="hs-identifier hs-var hs-var">mb_subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Maybe TCvSubst
</span><a href="GHC.Core.Unify.html#tcMatchTyKi"><span class="hs-identifier hs-var">tcMatchTyKi</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101052"><span class="hs-identifier hs-var">the_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681101084"><span class="hs-identifier hs-var">default_ty</span></a></span><span>
</span><span id="line-2782"></span><span>      </span><span class="hs-comment">-- Make sure the kinds match too; hence this call to tcMatchTyKi</span><span>
</span><span id="line-2783"></span><span>      </span><span class="hs-comment">-- E.g. suppose the only constraint was (Typeable k (a::k))</span><span>
</span><span id="line-2784"></span><span>      </span><span class="hs-comment">-- With the addition of polykinded defaulting we also want to reject</span><span>
</span><span id="line-2785"></span><span>      </span><span class="hs-comment">-- ill-kinded defaulting attempts like (Eq []) or (Foldable Int) here.</span><span>
</span><span id="line-2786"></span><span>
</span><span id="line-2787"></span><span class="hs-comment">-- In interactive mode, or with -XExtendedDefaultRules,</span><span>
</span><span id="line-2788"></span><span class="hs-comment">-- we default Show a to Show () to avoid graututious errors on &quot;show []&quot;</span><span>
</span><span id="line-2789"></span><span class="annot"><a href="GHC.Tc.Solver.html#isInteractiveClass"><span class="hs-identifier hs-type">isInteractiveClass</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>   </span><span class="hs-comment">-- -XOverloadedStrings?</span><span>
</span><span id="line-2790"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2791"></span><span id="isInteractiveClass"><span class="annot"><span class="annottext">isInteractiveClass :: Bool -&gt; Class -&gt; Bool
</span><a href="GHC.Tc.Solver.html#isInteractiveClass"><span class="hs-identifier hs-var hs-var">isInteractiveClass</span></a></span></span><span> </span><span id="local-6989586621681101051"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101051"><span class="hs-identifier hs-var">ovl_strings</span></a></span></span><span> </span><span id="local-6989586621681101050"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101050"><span class="hs-identifier hs-var">cls</span></a></span></span><span>
</span><span id="line-2792"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Class -&gt; Bool
</span><a href="GHC.Tc.Solver.html#isNumClass"><span class="hs-identifier hs-var">isNumClass</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101051"><span class="hs-identifier hs-var">ovl_strings</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101050"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; Unique
</span><a href="GHC.Core.Class.html#classKey"><span class="hs-identifier hs-var hs-var">classKey</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101050"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; [Unique] -&gt; Bool
forall (t :: * -&gt; *) a. (Foldable t, Eq a) =&gt; a -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#elem"><span class="hs-operator hs-var">`elem`</span></a></span><span> </span><span class="annot"><span class="annottext">[Unique]
</span><a href="GHC.Builtin.Names.html#interactiveClassKeys"><span class="hs-identifier hs-var">interactiveClassKeys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2793"></span><span>
</span><span id="line-2794"></span><span>    </span><span class="hs-comment">-- isNumClass adds IsString to the standard numeric classes,</span><span>
</span><span id="line-2795"></span><span>    </span><span class="hs-comment">-- when -foverloaded-strings is enabled</span><span>
</span><span id="line-2796"></span><span class="annot"><a href="GHC.Tc.Solver.html#isNumClass"><span class="hs-identifier hs-type">isNumClass</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>   </span><span class="hs-comment">-- -XOverloadedStrings?</span><span>
</span><span id="line-2797"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2798"></span><span id="isNumClass"><span class="annot"><span class="annottext">isNumClass :: Bool -&gt; Class -&gt; Bool
</span><a href="GHC.Tc.Solver.html#isNumClass"><span class="hs-identifier hs-var hs-var">isNumClass</span></a></span></span><span> </span><span id="local-6989586621681101047"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101047"><span class="hs-identifier hs-var">ovl_strings</span></a></span></span><span> </span><span id="local-6989586621681101046"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101046"><span class="hs-identifier hs-var">cls</span></a></span></span><span>
</span><span id="line-2799"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; Bool
</span><a href="GHC.Builtin.Utils.html#isNumericClass"><span class="hs-identifier hs-var">isNumericClass</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101046"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681101047"><span class="hs-identifier hs-var">ovl_strings</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681101046"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">Class -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#isStringClassKey"><span class="hs-identifier hs-var">isStringClassKey</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2800"></span><span>
</span><span id="line-2801"></span><span>
</span><span id="line-2802"></span><span class="hs-comment">{-
Note [Avoiding spurious errors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When doing the unification for defaulting, we check for skolem
type variables, and simply don't default them.  For example:
   f = (*)      -- Monomorphic
   g :: Num a =&gt; a -&gt; a
   g x = f x x
Here, we get a complaint when checking the type signature for g,
that g isn't polymorphic enough; but then we get another one when
dealing with the (Num a) context arising from f's definition;
we try to unify a with Int (to default it), but find that it's
already been unified with the rigid variable from g's type sig.

Note [Multi-parameter defaults]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
With -XExtendedDefaultRules, we default only based on single-variable
constraints, but do not exclude from defaulting any type variables which also
appear in multi-variable constraints. This means that the following will
default properly:

   default (Integer, Double)

   class A b (c :: Symbol) where
      a :: b -&gt; Proxy c

   instance A Integer c where a _ = Proxy

   main = print (a 5 :: Proxy &quot;5&quot;)

Note that if we change the above instance (&quot;instance A Integer&quot;) to
&quot;instance A Double&quot;, we get an error:

   No instance for (A Integer &quot;5&quot;)

This is because the first defaulted type (Integer) has successfully satisfied
its single-parameter constraints (in this case Num).
-}</span><span>
</span><span id="line-2840"></span></pre></body></html>